首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActiveCampaign axios post请求返回422

ActiveCampaign axios post请求返回422
EN

Stack Overflow用户
提问于 2020-04-21 21:04:16
回答 1查看 593关注 0票数 1

这是对象和post请求

代码语言:javascript
复制
let contactObject = {
    contact: {
        email: "jsmith@example.com",
        firstName: "John",
        lastName: "Smith"
    }
};

const options = {
    method: 'POST',
    headers: {
        'Api-Token': `${token}`,
        'content-type': 'application/json',
    },
    data: contactObject,
    url,
};

await axios(options);

这是我得到的回应

代码语言:javascript
复制
   "status": "error",
"error": {
    "message": "Request failed with status code 422",
    "name": "Error",
    "stack": "Error: Request failed with status code 422\n    at createError (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/adapters/http.js:236:11)\n    at IncomingMessage.emit (events.js:215:7)\n    at endReadableNT (_stream_readable.js:1184:12)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)",
    "config": {
        "url": "https://successroadacademy.api-us1.com/api/3/contacts",
        "method": "post",
        "data": "{\"contact\":{\"email\":\"jsmith@example.com\",\"firstName\":\"John\",\"lastName\":\"Smith\"}}",
        "headers": {
            "Accept": "application/json, text/plain, */*",
            "Content-Type": "application/json",
            "Api-Token": "APITOKEN",
            "User-Agent": "axios/0.19.2",
            "Content-Length": 80
        },
        "transformRequest": [
            null
        ],
        "transformResponse": [
            null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1
    }
},
"message": "Request failed with status code 422",
"stack": "Error: Request failed with status code 422\n    at createError (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/Users/robert/chatbots/truchat_helper_functions/node_modules/axios/lib/adapters/http.js:236:11)\n    at IncomingMessage.emit (events.js:215:7)\n    at endReadableNT (_stream_readable.js:1184:12)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)"

}

如果任何人知道可能是什么问题,请帮助我尝试了我能想到的一切。无论我如何改变数据对象或头请求,我总是得到相同的响应。

这是ActiveCampaign应用编程接口的链接

https://developers.activecampaign.com/reference#http-methods

EN

回答 1

Stack Overflow用户

发布于 2020-04-21 22:34:59

在与ActiveCampaign的支持人员交谈后,我找到了解决方案,这很棒

代码语言:javascript
复制
const email = req.body.email;
const name = req.body.firstName;
const last = req.body.lastName;
const phone = req.body.phone;

let contactObject = {
    "contact": {
        "email": email,
        "firstName": name,
        "lastName": last,
        "phone": phone
    }
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61344252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档