I'm trying to fetch data from the rainforestqa API but to gain access I need to send my api_key as a header. The code I already have is as follows,
var header = {
"access-control-allow-headers":"Content-Type",
"CLIENT_TOKEN" : "API-TOKEN"
};
var options = {
"method" : "post",
"header" : header
};
UrlFetchApp.fetch("https://app.rainforestqa.com:443/api/1/runs/TESTNUMBER/tests.json?result=failed", options);
But this returns 405 error. Does anyone have any ideas why this isn't working?
Thanks
It turns out the answer is as follows, I basically got to this via trial and error.
$var options = {
"async": true,
"crossDomain": true,
"method" : "GET",
"headers" : {
"CLIENT_TOKEN" : "my-api-key",
"cache-control": "no-cache"
}
};
var response = UrlFetchApp.fetch("https://app.rainforestqa.com:443/api/1/runs/test_id/tests.json?result=failed", options);
I believe you have misspelled the word headers
.
I know it is an old question, but I did not see this answer before and it might help others who arrive this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With