我构建了一个简单的 zapier 集成,并且运行良好。但是,我正在添加动态字段。当我测试 zap 时,一切似乎都完美地工作。我的动态表单字段正如我预期的那样显示。
问题是将这些动态表单的值发送到我的 API。我正在使用 zapier 控制台,当我配置 API 请求时,我使用以下内容:
其中 body['custom_fields']
应该发送我的所有动态字段甚至所有字段。但是当它到达我的 API custom_fields
参数时,它是空白的。
const options = {
url: 'https://example_url/endpoint',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${bundle.authData.auth_token}`
},
body: {
'email': bundle.inputData.email,
'custom_fields': bundle.inputData
/**
I've tried the following with no luck:
'custom_fields': bundle.inputData.fields
'custom_fields': bundle.inputData.undefined
'custom_fields': bundle.inputData
*/
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return results;
});
最佳答案
好吧,几天后,这是最简单的答案。
显然,对象不能通过参数发送。
所以而不是
'custom_fields': bundle.inputData
我只是将整个对象添加到参数中,它会处理所有键和值
params: bundle.inputData
这是全身
const options = {
url: 'https://apiendpoint.com',
method: 'POST',
headers: {
'Authorization': `Bearer ${bundle.authData.auth_token}`
},
params: bundle.inputData,
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return results;
});
关于zapier - 为什么我的 Zapier 集成动态字段不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61603815/