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
405is "Method not allowed", I assume the server doesn't allow a POST method on the resource you're trying to access. Have you tried a GET?GETI get a401which presumabley means that the header isn't being passed to the server and the authentication isn't working.access-control-allow-headers:Content-Type,CLIENT_TOKEN, which suggests to me that the API key header should be calledCLIENT_TOKEN. What happens if you change"api_key"to"CLIENT_TOKEN"?access-control-allow-headers-- that is for servers to send to clients. However, since you're getting a 401 response, that issue not what is causing your problem; it's simply needless code (but it would be problem if you tried it in a browser context).