我建立了一个简单的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;
});