gpt4 book ai didi

javascript - 事件事件 API : How to 'create or update contact' along with their custom field values?

转载 作者:行者123 更新时间:2023-12-05 01:13:21 35 4
gpt4 key购买 nike

我正在使用 Node js,我可以创建/更新联系人的电子邮件、姓名或电话号码。但是我从未更新过自定义字段。这是我到目前为止得到的结果。

 var data = JSON.stringify({
"contact": {
"email": "t@brady.com",
"firstName": "Tom",
"lastName": "Brady",
"phone": "111122233",
"myCustomField": "myValue"
}
});

var options = {
hostname: hostname,
path: '/api/3/contact/sync',
method: 'POST',
headers: {
'Api-Token': apiToken,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': data.length
}
}

var req = this.https.request(options, function(res){
});
req.on('error', function(err){
console.log('error: ' + err.message);
});
req.write(data);
req.end();

因此这将更新联系人的内置字段(电子邮件、姓名、电话),但不会更新 myCustomField。知道为什么吗?如何解决?如果有任何帮助,我将不胜感激。

附: myCustomField 存在于 Active Campaign 中。联系人只是没有值(value)。

最佳答案

首先,您需要获取自定义字段的字段 ID。您可以使用 postman 通过 GET 请求 https://youraccountname.api-us1.com/api/3/fields docs 执行此操作当您拥有要更新的 ID 时,您可以轻松地这样做。希望它有所帮助。在弄清楚这一点之前,我经历了很多苦难。

fetch(proxyurl + active_campaign_url, {
mode: "cors",
method: "POST",
body: JSON.stringify({
contact: {
firstName,
lastName,
email,
fieldValues: [
{
field: 1,
value: jobTitle,
},
{
field: 30,
value: companyName
}
],
},
}),
headers: headers,
})
.then((response) => response.json())**strong text**

关于javascript - 事件事件 API : How to 'create or update contact' along with their custom field values?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60468898/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com