问题
I'm trying to test the endpoints of an API and all the responses return blank with no errors.
I've tested using curl and the response actually has data in:
curl --request GET https://myapiurl.com/endpoint --header "authorization: bearer TOKEN"
Here's the segment of GAS code. The token property is set when I run a POST call to retrieve it, it expires after a while:
var url = 'https://myapiurl.com/endpoint';
var token = 'bearer TOKEN';
var headers = {
'authorization': token
};
var options = {
'headers' : headers
};
var response = UrlFetchApp.fetch(url,options);
var data = JSON.parse(response.getContentText());
The response should be a JSON object with a full list of keys/values. The response from curl is exactly what it should be, but the GAS version is blank, no errors.
I am completely at a loss, any help would be much appreciated!
来源:https://stackoverflow.com/questions/57631757/blank-response-from-urlfetchapp-in-google-app-script