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 badges
Add a ment  | 

1 Answer 1

Reset to default 7

First, 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 badges
Add a ment  | 

1 Answer 1

Reset to default 7

First, 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**

本文标签: