Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

POST request, 400 Bad Request Error - Content-Type header missing


Now I’m developing some automation framework integration TestRail using JAVA code. But I faced below issue, could you please kindly help? Thank you.

Pre-condition: Using the official binding for JAVA which named
I can get expected response for ‘sendGet’.

Issue: When I want to use ‘sendPost’ request, there is 400 Error as “Content-Type header missing (use Content-Type: application/json)”, the source code is below:

          Map data = new HashMap();
          data.put("description", "A description for the test run");
          JSONObject r = (JSONObject) client.sendPost("update_run/54859", data);


And I also try other command like add_run, add_results and all such commands get this error, but I can get successfully response for ‘sendGet’ using the same credential.

I also checked the source code in there is code: conn.addRequestProperty(“Content-Type”, “application/json”) to set Header.

What’s more, I used the Postman tool to send Post request also get the same error, the request is ‘’ and body is
“description”:“A description for the test run”


for me in Posteman following works:

  • set in tab Authorization: “Basic Auth” + Username: + Password: your password
  • add in tab Header: key|Value: “Content-Type”|“application/json”
  • add in tab body: (using raw)
    “description”: “A description for the test run”