【问题标题】:Zapier API Configuration: send form-data instead of json request bodyZapier API 配置:发送表单数据而不是 json 请求正文
【发布时间】:2020-05-24 20:56:56
【问题描述】:

我正在 Zapier 中为我们的应用程序设置 Zap。 但是,让 Zap 以正确的格式传递数据时遇到了一些麻烦。 默认情况下,Zapier 似乎将数据作为 json 请求正文传递,但我们的后端只接受表单数据。

是否可以将 Zap 配置为通过表单数据发送? 在下面的代码中,我尝试将数据作为paramsbody 发送,但我的后端没有任何作为表单数据:

const options = {
  url: '${URL}',
  method: 'POST',
  headers: {
    'Authorization': ${token},
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  params: {
    'phone': bundle.inputData.phone,
    'email': bundle.inputData.email,
    'dialog': bundle.inputData.dialog,
    'name': bundle.inputData.name
  },
  body: {
    'name': bundle.inputData.name,
    'email': bundle.inputData.email,
    'phone': bundle.inputData.phone,
    'dialog': bundle.inputData.dialog
  }
}

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = z.JSON.parse(response.content);

    // You can do any parsing you need for results here before returning them

    return results;
  });

非常感谢任何输入!

【问题讨论】:

    标签: zapier


    【解决方案1】:

    我通过将'Content-Type': 'application/json' 替换为'Content-Type': 'application/x-www-form-urlencoded' 来修复它。

    【讨论】:

      猜你喜欢
      • 2015-02-26
      • 1970-01-01
      • 2017-05-15
      • 2018-12-22
      • 1970-01-01
      • 2021-10-12
      • 2021-02-07
      • 2017-05-04
      • 2013-10-07
      相关资源
      最近更新 更多