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

Content-Type header invalid, use Content-Type: application\/json



I’m writing a POST code in Google Sheets script that will go through a test run export populated with results and push it into TR.
My code is as follows:
function constructApi() {
var headers =
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Basic ’ + Utilities.base64Encode(’’ + ‘:’ + ‘’),
var data =
“comments”:“Just testing stuff”,
var payload = JSON.stringify(data);

//also method and specifying the headers above
var options =
“headers” : headers,
“payload” : payload,

var runId = resolveRunId();
var response = UrlFetchApp.fetch(“https://<>”, options);


but I’m getting the following -
Request failed for https://<> returned code 400. Truncated server response: {“error”:“Content-Type header invalid (use Content-Type: application/json)”} (use muteHttpExceptions option to examine full response) (line 46, file “submitToTestRail”)

Content-Type is in fact application/json so it’s not clear what’s the problem. The same method, only with GET, is used in another script and it’s running just fine.



Hello Assaf,

Thanks for your posting. Could you please try to use the following instead?

‘Content-Type’: ‘application/json’,

(note the missing backslash)

Also please double-check that you really use https instead of http. We have seen this issue before when only http was used (due to headers not being resent after the redirect to https).



Hi Tobias,

I tried w/o the ‘’ and still without success. https:// is also in place.
The above is an exact copy-paste (minus the sensitive information).

Thanks again.


Thanks, Assaf. Do you have the option to take a look at the raw HTTP request that is sent? It could be that the UrlFetchApp API handles POST requests differently than GETs and does not include the Content-Type header or something else. If you have the option to review the actual HTTP request that is really sent, that would make it easier to troubleshoot.



URLFetchApp doesn’t support “Content-Type” headers for GET requests. This is correct, as the Content-Type header denotes the content type of the request body, which is unsupported for GET. The closest “correct” header would be “Accept” for the expected content type of the response body.

TestRail needs to remove the requirement or also allow the header in “Accept”


I’m having the same problem. Content-Type is not a valid header for get requests and several http libraries forbid it. After 2 years, can we get this check removed? It’s putting a hold to several integration projects we are working on.

Referencing another case: Making an API GET request without the header Content-Type


Hi everyone,

We are happy to look into this, thanks for your feedback!