Setting Content-Type application/json in HeaderManager and passing to Jmeter, but is being overriden while being called as text/plain
HeaderManager headerManager = new HeaderManager();
headerManager.add(createHeader("Content-Type", "application/json"));
HTTPSamplerProxy httpSampler = new HTTPSamplerProxy();
httpSampler.setProtocol("https");
httpSampler.setDomain(config.getString("JMETER_DOMAIN"));
httpSampler.setPath(api);
httpSampler.setMethod(method);
TestPlan testPlan = new TestPlan("MY TEST PLAN");
// Add elements to HashTree
ListedHashTree testPlanTree = new ListedHashTree();
testPlanTree.add(testPlan);
ListedHashTree threadGroupTree = new ListedHashTree(threadGroup);
threadGroupTree.add(httpSampler,headerManager);
testPlanTree.add(testPlan, threadGroupTree);
// Run Test Plan
jm.configure(testPlanTree);
jm.run();
O/p
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /auth/Authentication/login HTTP/1.1
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: close
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 33
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: text/plain
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: example.com
14:26:57.653 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.14 (Java/1.8.0_372)
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 415 Unsupported Media Type
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Tue, 18 Jul 2023 14:26:57 GMT
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/problem+json; charset=utf-8
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: close
14:26:57.672 [ 1-1] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Kestrel
14:26:57.680 [ 1-1] INFO org.apache.jmeter.threads.JMeterThread - Thread is done: 1-1
14:26:57.680 [ 1-1] INFO org.apache.jmeter.threads.JMeterThread - Thread finished: 1-1
How do i change the content-type as per my requirement and avoid jmeter overriding it
Tried using HeaderManager but no luck yet