问题描述
我有一个使用输入字段的Zapier和一个动态字段,用于从电子邮件营销平台中提取和收集自定义字段数据。
通常在传递信息时,我会使用输入字段中的键。动态字段中没有键。
我还添加了我的代码以传递到目前为止的输入字段。我还需要为动态内容传递一个以上的项目,不确定是否会是if语句以及如何执行。
动态域代码:
// Configure a request to an endpoint of your api that
// returns custom field Meta data for the authenticated
// user. Don't forget to congigure authentication!
const options = {
url: 'https://edapi.example.com/v1/Database',method: 'GET',headers: {
'X-API-KEY': bundle.authData.ApiKey
},params: {
'ApiKey': bundle.authData.ApiKey
}
};
return z.request(options).then((response) => {
response.throwForStatus();
const results = response.json;
var col = results.DatabaseColumns.filter((item) => item.IsCustom).map((item) => {
return {
...item,key: item["ColumnName"],value: item["ColumnName"]
};
});
//var col = col.filter(items => ['FirstName','LastName'].indexOf(items) >= 0 )
for (var i = col.length; i--;) {
if (col[i].key === 'FirstName' || col[i].key === 'LastName' ) {
col.splice(i,1);
}
}
return col});
/*
return [
{
"key": "FirstName","value":"First Name"
},{
"key": "LastName","value": "Last Name"
},{
"key": "Test","value": "Test 2"
},*/
迄今发布API代码:
const options = {
url: 'https://edapi.example.com/v1/Subscribers',method: 'POST',headers: {
'Content-Type': 'application/json','Accept': 'application/json','X-API-KEY': bundle.authData.ApiKey
},params: {
'ApiKey': bundle.authData.ApiKey
},body: {
'EmailAddress': bundle.inputData.EmailAddress,'CustomFields':[
{
'FieldName':'FirstName','Value':bundle.inputData.FirstName,},{
'FieldName':'LastName','Value':bundle.inputData.LastName,{
'FieldName':'FirstName',],'Lists':[
bundle.inputData.ListID,]}};
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;
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)