Hi,
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('<username>' + ':' + '<password>'),
};
var data =
{
"status_id":"1",
"comments":"Just testing stuff",
"assignedto_id":"1",
};
var payload = JSON.stringify(data);
//also method and specifying the headers above
var options =
{
"method":"POST",
"headers" : headers,
"payload" : payload,
};
var runId = resolveRunId();
//Logger.log(options.results[0].case_id);
var response = UrlFetchApp.fetch("https://<>.testrail.net/index.php?/api/v2/add_result_for_case/94/341", options);
[..]
but I'm getting the following -
[..]
Request failed for https://<>.testrail.net/index.php?/api/v2/add_result_for_case/94/341 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.
Thanks.