2

我正在尝试使用此处的“创建或更新 api”创建联系人:https://developers.activecampaign.com/reference#create-or-update-contact-new

我尝试调用 cURL 命令,它给出了正确的响应,但是从 axios 执行它时会出错。

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

代码:

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);
  });

此外,在网络选项卡中看不到请求参数,也没有收到响应。控制台错误是: 在此处输入图像描述

4

0 回答 0