2

これはオブジェクトと投稿リクエストです

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

これは私が得る応答です

   "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 API へのリンクです

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

4

1 に答える 1