我正在尝试从此处使用“create or update API”创建联系人:https://developers.activecampaign.com/reference#create-or-update-contact-new
我试着调用cURL命令,它给出了一个正确的响应,但当从axios执行时,它给出了错误。
API:https://deskera4783.api-us1.com/api/3/contact/sync方法:邮政
代码:
var axios = require("axios");
var data = ({
contact: {
email: "[email protected]",
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);
});
此外,在网络选项卡中,看不到请求参数,也没有收到响应。控制台错误是:enter image description here
1条答案
按热度按时间wz8daaqr1#
由于这个问题:https://github.com/ActiveCampaign/activecampaign-api-nodejs/issues/63
活动活动似乎不支持客户端请求
因此,您需要有一个后端或其他东西作为调用API的中间件
在我的例子中,我使用和nodejs BE来调用API