Zapier API配置:发送表单数据而不是json请求正文

问题描述 投票:0回答:1

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

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

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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.