为了账号安全,请及时绑定邮箱和手机立即绑定

尝试在Google Apps脚本中将Stripe API密钥添加到UrlFetchApp时收到401

尝试在Google Apps脚本中将Stripe API密钥添加到UrlFetchApp时收到401

月关宝盒 2021-04-06 17:18:53
我正在尝试通过Stripe API在Google表格中检索发票,并且正在使用Google Apps脚本来运行我的代码。这是我的代码:function callNumbers()   {    var url = "https://api.stripe.com/v1/invoices/[unique_id]";    var apiKey = "[api-key]";    var response = UrlFetchApp.fetch(url, {"headers":{"[api-key]":apiKey}});     var content = response.getContentText();     Logger.log(response);     Logger.log(content); }条纹发票URL在/ invoices /之后的上方url中具有唯一ID,代表我要检索的特定测试发票。我正在使用测试Stripe API密钥,从此开始,在唯一的API密钥代码之前:sk_test_条带页面上的引用如下所示:curl https://api.stripe.com/v1/invoices/[unique_id] \  -u sk_test_[api-key]:我收到的错误消息如下所示:Request failed for https://api.stripe.com/v1/invoices/[unique_id] returned code 401. Truncated server response: { "error": { "message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g... (use muteHttpExceptions option to examine full response) (line 13, file "Code")我不确定我的代码有什么问题。我猜这"headers"部分内容,但是我对API的了解还不够。我正在使用此测试项目,以尝试了解有关API的更多信息。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 192 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信