I'm using a google script to connect to an external API with the code:
var url='https://app.ecwid.com/api/v1/XXX/orders'
var parameters = { method : 'get',
headers : {'Authorization': 'Bearer '+'yyy'},
contentType:'application/json',
muteHttpExceptions:true};
var response = UrlFetchApp.fetch(url,parameters).getContentText();
Logger.log(response);
But why is this returning the following error?
HTTP ERROR 401
Problem accessing /api/v1/XXX/orders. Reason:
Unauthorized
Try removing the contentType from parameters and give it a shot.
For cross-domain requests, setting the content type to anything other than
will trigger the browser to send a preflight OPTIONS request to the server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.