Skip to content

JMeter HTTP 400 Bad Request & 415 Unsupported Media Type

Fix JMeter HTTP 400 Bad Request and 415 Unsupported Media Type errors. Configure HTTP Header Manager, Content-Type headers, and JSON body payloads correctly.

Difficulty
beginner
Guide type
troubleshooting
Estimated read time
5 min read
Last verified version
Verified JMeter 5.6

HTTP 400 Bad Request & 415 Unsupported Media Type in JMeter

Section titled “HTTP 400 Bad Request & 415 Unsupported Media Type in JMeter”

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 Type

Or for payload validation issues:

Response code: 400 (Bad Request)
Response message: Bad Request

The response body typically explains that the server cannot parse the incoming payload or that the Content-Type header is missing or unexpected.

  • HTTP 415: The API endpoint requires 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.
  • HTTP 400: The payload syntax is malformed (e.g. unescaped quotes in JSON strings, missing required parameters, or invalid variable interpolation like {"name": \${var}} without quotes).
CauseStatusWhy it happens
Missing Content-Type header415JMeter HTTP Request does not include Content-Type by default without an HTTP Header Manager
Wrong Header Manager scope415HTTP Header Manager placed under a different Thread Group or sampler, leaving child samplers without headers
Unquoted variable in JSON400Writing {"id": \${userId}} where userId is a string value, resulting in invalid JSON {"id": abc}
Multipart form data checkbox415 / 400Checking “Use multipart/form-data” for standard raw JSON body payloads
Malformed JSON quotes / newlines400CSV variables containing unescaped double quotes (") or literal newlines breaking JSON schema validation

1. Add HTTP Header Manager at the Test Plan or Thread Group Level

Section titled “1. Add HTTP Header Manager at the Test Plan or Thread Group Level”

To ensure every REST API request transmits the proper headers:

  1. Right-click your Thread Group -> Add -> Config Element -> HTTP Header Manager.
  2. Add the standard REST API headers:
NameValue
Content-Typeapplication/json; charset=UTF-8
Acceptapplication/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>

2. Configure the “Body Data” Tab (Do Not Mix with Parameters)

Section titled “2. Configure the “Body Data” Tab (Do Not Mix with Parameters)”

In your HTTP Request sampler:

  1. Select the Body Data tab (not the Parameters tab).
  2. Uncheck Use multipart/form-data (unless performing actual file uploads).
  3. Ensure strings inside JSON payloads are wrapped in quotes:
{
"username": "${username}",
"email": "${email}",
"age": ${age}
}

3. Handle Escaped JSON Strings with __groovy()

Section titled “3. Handle Escaped JSON Strings with __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')))}

4. Inspect Request Headers in View Results Tree

Section titled “4. Inspect Request Headers in View Results Tree”

To verify what headers JMeter actually sent over the wire:

  1. Run with 1 thread in GUI.
  2. Select the failed sampler in View Results Tree.
  3. Open the Request tab -> Request Headers sub-tab.
  4. Verify that Content-Type: application/json is present and matches API documentation.
ResourceUse when
401/403 after recordingAuthentication and authorization header issues
API load testingFull end-to-end API load testing tutorial
Correlation & dynamic valuesExtracting and passing dynamic tokens in headers
Properties Cheat SheetQuick lookup of JMeter configuration elements

Can I set different Content-Type headers for different samplers?

Section titled “Can I set different Content-Type headers for different samplers?”

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.

Why does JMeter change my JSON payload into form parameters?

Section titled “Why does JMeter change my JSON payload into form parameters?”

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.

On this page