【问题标题】:fetch not posting form data in zapier获取不在zapier中发布表单数据
【发布时间】:2018-12-22 10:30:27
【问题描述】:

我在 zapier 中有一个代码:

var username = "username"
var password = "password"
var grant_type = "password"
var client_id = "id"
var ENDPOINT="someUrl"
var json = {
      "grant_type": grant_type,
      "username": username,
      "password": password,
      "client_id": client_id
};
var options={
  method:"POST",
  headers: {
   'Accept': 'application/json',
   'Content-Type': 'application/json'
  },
  payload:json
}
const result = await fetch(WAVITY_ENDPOINT,options)
const content = await result.json()
output={response:content}

但我总是收到未经授权的错误。我通过请求模块做同样的事情并且它有效。我认为 fetch 没有发送数据。任何帮助将不胜感激。在我的请求模块代码中,我有以下选项:

headers: {
        connection: "Keep-Alive",
        timeout: 5000
      },
      url: ENDPOINT,
      method: 'POST',
      formData: {
        'grant_type': grant_type,
        'username': username,
        'password': password,
        'client_id': client_id
      }

注意:将 fetch 的标头更改为请求中的标头也不适合我。

【问题讨论】:

  • 只想先做个小检查,确保您在 fetch 中使用的端点变量与第 5 行所述的变量相同(您在第 5 行声明了“ENDPOINT”,然后将其称为WAVITY_ENDPOINT)

标签: node.js zapier


【解决方案1】:

根据this question about fetch,我认为数据的键应该是body,而不是payload

Zapier 使用node-fetch (source),所以如果你可以让它在本地工作,你就可以成功地将它粘贴到 Zapier 中。

【讨论】:

    猜你喜欢
    • 2021-05-24
    • 1970-01-01
    • 2014-04-27
    • 2021-03-21
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    相关资源
    最近更新 更多