HTTP Request node - On Error Continue - seems to break the formatting of the response?

Describe the problem/error/question

When using an HTTP Request and choosing for “On Error: Continue”, in an error scenario the Output of the node (the JSON response from the API) seems to be broken because the Status Code is prefixed in the response message. Also the response is available as vale in a string called “message“ which lives in an object called “error” while a Status Code 200OK is not prefixed in the response message and the JSON response is available without any changes.
I’m using the JSON response further in another flow, but I can’t use it in the on error scenario

What is the error message (if any)?


[
{
"error": 
{
"message": 
"409 - \"{\\\"status\\\":\\\"fail\\\",\\\"data\\\":
...
"code": 
"ERR_BAD_REQUEST",
"status": 
409
}
}
]

Please share your workflow

Share the output returned by the last node

[
{
“error”: {
“message”: “409 - "{\"status\":\"fail\",\"data\":{\"track\":\"imola\",\"preRaceWaitingTimeSeconds\":80,\"postRaceSeconds\":180,\"sessionOverTimeSeconds\":180,\"ambientTemp\":15,\"cloudLevel\":0.2,\"rain\":0.0,\"weatherRandomness\":1,\"simracerWeatherConditions\":0,\"isFixedConditionQualification\":0,\"sessions\":[{\"hourOfDay\":13,\"dayOfWeekend\":3,\"timeMultiplier\":1,\"sessionType\":\"P\",\"sessionDurationMinutes\":60}],\"configVersion\":1,\"serverName\":\"\",\"adminPassword\":\"\",\"password\":\"\",\"spectatorPassword\":\"\",\"centralEntryListPath\":\"\",\"carGroup\":\"GTC\",\"trackMedalsRequirement\":0,\"safetyRatingRequirement\":20,\"racecraftRatingRequirement\":-1,\"maxCarSlots\":40,\"isRaceLocked\":0,\"isLockedPrepPhase\":0,\"shortFormationLap\":1,\"dumpLeaderboards\":1,\"dumpEntryList\":1,\"randomizeTrackWhenEmpty\":0,\"allowAutoDQ\":0,\"ignorePrematureDisconnects\":0,\"formationLapType\":3}}"”,
“name”: “AxiosError”,
“stack”: “AxiosError: Request failed with status code 409\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:565:9)\n at RedirectableRequest.emit (node:events:530: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:633:26)\n at ClientRequest.emit (node:events:518: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]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:272:10)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:648:20)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:1697:4)”,
“code”: “ERR_BAD_REQUEST”,
“status”: 409
}
}
]

Success output

[
  {
    "status": "success",
    "data": {
      "track": "imola",
      "preRaceWaitingTimeSeconds": 120,
      "postRaceSeconds": 180,
      "sessionOverTimeSeconds": 120,
      "ambientTemp": 15,
      "cloudLevel": 0.2,
      "rain": 0,
      "weatherRandomness": 1,
      "simracerWeatherConditions": 0,
      "isFixedConditionQualification": 0,
      "sessions": [
        {
          "hourOfDay": 11,
          "dayOfWeekend": 3,
          "timeMultiplier": 1,
          "sessionType": "P",
          "sessionDurationMinutes": 65
        },
        {
          "hourOfDay": 12,
          "dayOfWeekend": 3,
          "timeMultiplier": 1,
          "sessionType": "Q",
          "sessionDurationMinutes": 10
        },
        {
          "hourOfDay": 13,
          "dayOfWeekend": 3,
          "timeMultiplier": 1,
          "sessionType": "R",
          "sessionDurationMinutes": 20
        }
      ],
      "configVersion": 1,
      "serverName": "",
      "adminPassword": "",
      "password": "",
      "spectatorPassword": "",
      "centralEntryListPath": "",
      "carGroup": "GTC",
      "trackMedalsRequirement": 0,
      "safetyRatingRequirement": -1,
      "racecraftRatingRequirement": -1,
      "maxCarSlots": 40,
      "isRaceLocked": 0,
      "isLockedPrepPhase": 0,
      "shortFormationLap": 1,
      "dumpLeaderboards": 1,
      "dumpEntryList": 1,
      "randomizeTrackWhenEmpty": 0,
      "allowAutoDQ": 0,
      "ignorePrematureDisconnects": 0,
      "formationLapType": 3
    }
  }
]

Information on your n8n setup

  • n8n version: 1.117.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

hello @wlevels

That’s not an issue. You have a proper code and status in the response. The details will be in the message property, which is always a string, because there is no guarantee that the service will output a correct JSON object. You may receive a network error or any other kind of errors, which do not always relate to the HTTP

1 Like

Thanks for the response. I’m still pretty new to this so maybe the answer to my question is pretty easy, but how could I work around this as in this scenario for a 409 status code I still want to parse/use the response in a next node? Thanks!

I was able to fix the formatting with a function node

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.