Next Practical Step
Add an HTTP Header Manager with Content-Type: application/json to your Thread Group and verify the Body Data tab in your samplers.
Fix JMeter HTTP 400 Bad Request and 415 Unsupported Media Type errors. Configure HTTP Header Manager, Content-Type headers, and JSON body payloads correctly.
When executing REST API requests in View Results Tree or JTL results, samplers return client-side HTTP 4xx error codes:
Response code: 415 (Unsupported Media Type)Response message: Unsupported Media TypeOr for payload validation issues:
Response code: 400 (Bad Request)Response message: Bad RequestThe response body typically explains that the server cannot parse the incoming payload or that the Content-Type header is missing or unexpected.
Content-Type: application/json (or application/xml), but JMeter sent the request without a Content-Type header (or sent default text/plain). Add an HTTP Header Manager.{"name": \${var}} without quotes).| Cause | Status | Why it happens |
|---|---|---|
Missing Content-Type header | 415 | JMeter HTTP Request does not include Content-Type by default without an HTTP Header Manager |
| Wrong Header Manager scope | 415 | HTTP Header Manager placed under a different Thread Group or sampler, leaving child samplers without headers |
| Unquoted variable in JSON | 400 | Writing {"id": \${userId}} where userId is a string value, resulting in invalid JSON {"id": abc} |
| Multipart form data checkbox | 415 / 400 | Checking “Use multipart/form-data” for standard raw JSON body payloads |
| Malformed JSON quotes / newlines | 400 | CSV variables containing unescaped double quotes (") or literal newlines breaking JSON schema validation |
To ensure every REST API request transmits the proper headers:
| Name | Value |
|---|---|
Content-Type | application/json; charset=UTF-8 |
Accept | application/json |
<!-- HTTP Header Manager configuration in JMX --><HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager"> <collectionProp name="HeaderManager.headers"> <elementProp name="" elementType="Header"> <stringProp name="Header.name">Content-Type</stringProp> <stringProp name="Header.value">application/json</stringProp> </elementProp> <elementProp name="" elementType="Header"> <stringProp name="Header.name">Accept</stringProp> <stringProp name="Header.value">application/json</stringProp> </elementProp> </collectionProp></HeaderManager>In your HTTP Request sampler:
{ "username": "${username}", "email": "${email}", "age": ${age}}__groovy()If CSV data contains special characters, quotes, or newlines, use Groovy’s JsonOutput.toJson() to safely escape strings:
${__groovy(groovy.json.JsonOutput.toJson(vars.get('csv_text_column')))}To verify what headers JMeter actually sent over the wire:
Content-Type: application/json is present and matches API documentation.| Resource | Use when |
|---|---|
| 401/403 after recording | Authentication and authorization header issues |
| API load testing | Full end-to-end API load testing tutorial |
| Correlation & dynamic values | Extracting and passing dynamic tokens in headers |
| Properties Cheat Sheet | Quick lookup of JMeter configuration elements |
Yes. Place an HTTP Header Manager directly as a child of a specific HTTP Request sampler to override the parent Thread Group’s headers for that individual request.
If you add rows to the “Parameters” tab of an HTTP Request, JMeter switches to application/x-www-form-urlencoded. Always clear the Parameters tab when using the “Body Data” tab for raw JSON payloads.