Describe the problem/error/question
Hi,
When webhook responses with HTTP status code 500 with JSON data payload, how can I access the data payload using HTTP Request node Error branch? For example, in Axios, when I call my webhook, I am able to access error.response.data as follows :
const axios = require('axios');
axios.post('http://datoslab3:5678/webhook/45d8b7ce-bc53-4686-a28e-d6e020726f70')
.then(response => {
//console.log(response.data);
console.log("All good");
})
.catch(error => {
// console.error(error);
console.log(typeof error.status);
console.log(error.response.data);
});
However, in the HTTP Request node, the JSON output does not appear to provide the data payload as a field. I would like to programmatically interrogate the data payload, in JSON format, to route/handle the error.
What is the error message (if any)?
Please share your workflow
Share the output returned by the last node
[
{
“error”: {
“message”: “500 - "{\"myField\":\"value\"}"”,
“name”: “AxiosError”,
“stack”: “AxiosError: Request failed with status code 500\n at settle (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/settle.js:19:12)\n at RedirectableRequest.handleResponse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/adapters/http.js:547:9)\n at RedirectableRequest.emit (node:events:531:35)\n at RedirectableRequest.processResponse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/follow-redirects/index.js:409:10)\n at ClientRequest.RedirectableRequest.onNativeResponse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/follow-redirects/index.js:102:12)\n at Object.onceWrapper (node:events:634:26)\n at ClientRequest.emit (node:events:519:28)\n at HTTPParser.parserOnIncomingClient (node:http_client:716:27)\n at HTTPParser.parserOnHeadersComplete (node:http_common:117:17)\n at Socket.socketOnData (node:http_client:558:22)\n at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/Axios.js:45:41)\n at processTicksAndRejections (node:internal/process/task_queues:105:5)\n at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]@[email protected]_5aee33ef851c7de341eb325c6a25e0ff/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:313:10)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]@[email protected]_5aee33ef851c7de341eb325c6a25e0ff/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:695:20)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]_@[email protected]_5aee33ef851c7de341eb325c6a25e0ff/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:1749:4)”,
“code”: “ERR_BAD_RESPONSE”,
“status”: 500
}
}
]
Information on your n8n setup
- n8n version: 1.109.2
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system:
