api - Google Scripts 应用程序和 Plaid 链接身份验证

我正在尝试创建一些代码来将我的银行交易下载到谷歌表格。我正在尝试通过使用谷歌脚本并对 Plaid 进行 API 调用来做到这一点。我目前设置了一个免费的沙盒帐户,但在过去几天尝试了几种方法后仍无法成功进行 api 调用。我还下载了 Postman,并从那里成功调用了电话。

这是我希望返回链接标记的代码主体。 ( Plaid Docs ) 我认为这是实现这一切的第一步。 ( Plaid Docs )

//1 - 创建链接 token

  var data = {
   "client_id":"redacted",
   "secret":"redacted",
   "client_name":"Google Sheets Money",
   "country_codes":[
      "CA"
   ],
   "language":"en",
   "user":{
      "client_user_id":"unique_user_id"
   },
   "products":[
      "auth",
      "transactions"
   ]
 };
  
 var json = JSON.stringify(data);
  
 var options = {
     "method": "POST",
     "contentType": "application/json",
      "body": json,
      "muteHttpExceptions": true,
  };
  

  var response = UrlFetchApp.fetch("https://sandbox.plaid.com/link/token/create", options);

  Logger.log(response);

这是我的记录器所说的:

{
  "display_message": null,
  "documentation_url": "https://plaid.com/docs/?ref=error#invalid-request-errors",
  "error_code": "INVALID_BODY",
  "error_message": "body could not be parsed as JSON",
  "error_type": "INVALID_REQUEST",
  "request_id": "0A86SP6KUD02oES",
  "suggested_action": null
}

一些谷歌搜索让我从标题部分移动了我的 contentType。我已经通过在线格式检查器运行我的 JSON,并且尝试过使用和不使用 stringify 选项发送 json。

谁能看出我可能遗漏了什么?我相信这是可能的,因为我已经看到至少一个似乎将 Plaid 与 Google 表格集成的附加解决方案。 BudgetSheets我有兴趣自己构建解决方案。

谢谢

最佳答案

您确定要发送 JSON 吗? documentation for UrlFetchApp.fetch没有提到 body 选项参数,而是使用 payload 参数。另外,我不确定它是否区分大小写,但以防万一,它的文档使用小写的 http 方法而不是大写的方法毫无意义。

https://stackoverflow.com/questions/63769552/

相关文章:

reactjs - reactstrap Collapse 没有出现在手机上

python - "An error occurred initiating application

python - 在 Web 应用中使用 SAML 实现 Azure AD 身份验证

css - 如何将边框颜色作为线性渐变放在表格行边框上?

python - 在pygame中的数组支持网格中交换颜色的问题

python - Plotly 多类别 X 轴排序

python - Python 中 + (pos) 一元运算符的用途是什么?

c# - 如何使 flutter 应用程序的 http 获取请求到本地主机?

python - 在条件下填充 df 的行

html - 根据自身内容调整banner高度