Google 脚本应用程序和 Plaid Link 身份验证

Google Scripts App and Plaid Link Authentication

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

这是我的代码的主要 body,我希望它成为 return 一个 link 标记。 (Plaid Docs) This is what I believe to be the first step in making this all happen. (Plaid Docs)

// 1 - 创建一个 Link 令牌

  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
}

一些谷歌搜索让我从 headers 部分移动了我的 contentType。我已经 运行 我的 JSON 通过在线格式检查器,我已经尝试过发送 json 有无 stringify 选项。

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

谢谢

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