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 APIClient.java.
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); log.info(r.toJSONString());
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 APIClient.java 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 ‘https://adcl-testrail.amazon.com/testrail/api/v2/update_run/54859’ and body is
“description”:“A description for the test run”