admin管理员组文章数量:1022752
I’m using Node js, and I can create/update a contact’s email, name, or phone number. But the custom fields I have never get updated. Here’s what I got so far.
var data = JSON.stringify({
"contact": {
"email": "[email protected]",
"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();
So this will update the contact's built-in fields (email, name, phone) but not myCustomField. Any idea why? How to solve it? I would really appreciate any help.
P.S. myCustomField exists in Active Campaign. The contact just doesn't have a value for it.
I’m using Node js, and I can create/update a contact’s email, name, or phone number. But the custom fields I have never get updated. Here’s what I got so far.
var data = JSON.stringify({
"contact": {
"email": "[email protected]",
"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();
So this will update the contact's built-in fields (email, name, phone) but not myCustomField. Any idea why? How to solve it? I would really appreciate any help.
P.S. myCustomField exists in Active Campaign. The contact just doesn't have a value for it.
Share Improve this question asked Feb 29, 2020 at 19:34 Magdi GamalMagdi Gamal 6781 gold badge12 silver badges28 bronze badges1 Answer
Reset to default 7First, you need to get the filed id of the custom fields. You can do this with postman with GET
request https://youraccountname.api-us1./api/3/fields
docs and when you have the ids that you want to update you can easily do it like this. Hope it help. I was struggling a lot before I figured this out.
fetch(proxyurl + active_campaign_url, {
mode: "cors",
method: "POST",
body: JSON.stringify({
contact: {
firstName,
lastName,
email,
fieldValues: [
{
field: 1,
value: jobTitle,
},
{
field: 30,
value: panyName
}
],
},
}),
headers: headers,
})
.then((response) => response.json())**strong text**
I’m using Node js, and I can create/update a contact’s email, name, or phone number. But the custom fields I have never get updated. Here’s what I got so far.
var data = JSON.stringify({
"contact": {
"email": "[email protected]",
"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();
So this will update the contact's built-in fields (email, name, phone) but not myCustomField. Any idea why? How to solve it? I would really appreciate any help.
P.S. myCustomField exists in Active Campaign. The contact just doesn't have a value for it.
I’m using Node js, and I can create/update a contact’s email, name, or phone number. But the custom fields I have never get updated. Here’s what I got so far.
var data = JSON.stringify({
"contact": {
"email": "[email protected]",
"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();
So this will update the contact's built-in fields (email, name, phone) but not myCustomField. Any idea why? How to solve it? I would really appreciate any help.
P.S. myCustomField exists in Active Campaign. The contact just doesn't have a value for it.
Share Improve this question asked Feb 29, 2020 at 19:34 Magdi GamalMagdi Gamal 6781 gold badge12 silver badges28 bronze badges1 Answer
Reset to default 7First, you need to get the filed id of the custom fields. You can do this with postman with GET
request https://youraccountname.api-us1./api/3/fields
docs and when you have the ids that you want to update you can easily do it like this. Hope it help. I was struggling a lot before I figured this out.
fetch(proxyurl + active_campaign_url, {
mode: "cors",
method: "POST",
body: JSON.stringify({
contact: {
firstName,
lastName,
email,
fieldValues: [
{
field: 1,
value: jobTitle,
},
{
field: 30,
value: panyName
}
],
},
}),
headers: headers,
})
.then((response) => response.json())**strong text**
本文标签:
版权声明:本文标题:javascript - Active Campaign API: How to 'create or update contact' along with their custom field values? - Stac 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745567111a2156516.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论