3
我使用谷歌的脚本与代码连接到一个外部API:谷歌应用程序脚本连接返回错误401
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);
但为什么这返回下面的错误?
HTTP ERROR 401
Problem accessing /api/v1/XXX/orders. Reason:
Unauthorized
谢谢,我试着删除contentType和我得到了同样的错误。 – 2014-11-21 10:53:58
您是否发送了正确的参数集?你应该在参数中发送一个secure_auth_key,否则会导致401错误。 http://help.ecwid.com/customer/portal/articles/1166917-order-api#Parameters – Tushar 2014-11-21 11:00:49
我在标题参数中发送密钥。 'yyy'在我上面的代码中。 – 2014-11-21 11:03:52