3

I am trying to create a contact using "create or update api" from here: https://developers.activecampaign.com/reference#create-or-update-contact-new

I tried calling the cURL command which gives a proper response but while doing it from axios it gives error.

API: https://deskera4783.api-us1.com/api/3/contact/sync Method: POST

Code:

var axios = require("axios");
var data = ({
  contact: {
    email: "jondoe@example.com",
    firstName: "John",
    lastName: "Doe",
    phone: "7223224241",
    fieldValues: [
      { field: "1", value: "The Value for First Field" },
      { field: "6", value: "2008-01-20" },
    ],
  },
});


var config = {
  method: "post",
  url: "https://deskera4783.api-us1.com/api/3/contact/sync",
  headers: {
    "Api-Token":
      "XXX",
    "Content-Type": "application/json",
    Cookie:
      "cmp800513081=0c7070adc5cdc923a8922c47e98dbe77; PHPSESSID=d3e534f9b1a3f61316cd2cf89b41f164; em_acp_globalauth_cookie=caea42ae-d440-4491-9c08-d920b3378638",
  },
  data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });

Also, in the network tab request params are not seen neither the response is received. Console error is: enter image description here

1 Answers1

0

Due to this issue: https://github.com/ActiveCampaign/activecampaign-api-nodejs/issues/63

It seems like active campaign doesn't support client side request

So you need to have a backend or something as a middleware for calling the api

In my case, I am using and nodejs BE to call the api

Bùi Anh Khoa
  • 82
  • 1
  • 5