Http node error 400 not handled

I’m using HTTP request node and sometimes I’m getting HTTP 400 errors.

The node window shows only that the request was rejected with error 400 and a stack trace, the node connected afterwards doesn’t get invoked, neither does Error Trigger in the workflow.

Am I missing something?

Hi @mattesilver

When you want it to continue on fail you will have te set this in the setting of the node:

Haven’t used the error trigger yet, but I am guessing that would be a setting as well.

Thanks @BramKnuever.

As for the error trigger @mattesilver, this would only run when the failing workflow (the one with the HTTP Request node) has an error workflow set.

If the workflow fails, the error workflow would then start at the error trigger:

I’ve created a simple error workflow with an error trigger and a slack message. it tests and sends a test message to my slack channel.
I\ve set it as the error workflow for my n8n instance.
The other workflow with HTTP still errs and error handler doesn’t get invoked.

That only makes it fail for each item.
And I can only get an item with the stack trace and not the server response

If you don’t want to stop exececution on errors you can use the Continue On Fail option suggested by @BramKnuever above which would do the trick and continue even on errors. You’d just need to make sure to handle the error case afterwards.

Specifically for the HTTP Request node you could alternatively use the Ignore Response Code option:
image

But you’d still need to then implement your own check whether the response matches your expectations or not. This could look like so:

Example Workflow
{
  "nodes": [
    {
      "parameters": {
        "functionCode": "const urls = ['https://mock.codes/200', 'https://mock.codes/201', 'https://mock.codes/202', 'https://mock.codes/201', 'https://mock.codes/400', 'https://mock.codes/502'];\n\nreturn urls.map(e => {\n  return {\n    json: {\n      url: e\n    }\n  }\n});\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const urls = ['https://mock.codes/200', 'https://mock.codes/201', 'https://mock.codes/202', 'https://mock.codes/201', 'https://mock.codes/400', 'https://mock.codes/502'];\n\nreturn urls.map(e => {\n  return {\n    json: {\n      url: e\n    }\n  }\n});\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{$json[\"url\"]}}",
        "options": {
          "fullResponse": true,
          "ignoreResponseCode": true
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"statusCode\"]}}",
              "value2": 300
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {},
      "name": "Error Path",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1120,
        400
      ]
    },
    {
      "parameters": {},
      "name": "Success Path",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1120,
        200
      ]
    }
  ],
  "connections": {
    "Function": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Success Path",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

The Function node in the above example just sets a couple of dummy URLs to use for testing, the HTTP Request and IF nodes are the ones making the request and checking how it went.

I need to see the HTTP response body. I guess my best shot is ignoring the error codes and handling it in the next node.

Still, the error handler workflow isn’t called in either case

So I’ve just tested the error flow upon running into an HTTP Error code and this is working fine for me:
image

As shown above, the HTTP Request node of my “HTTP Error” flow produces a 400 status. My “Error Flow” then runs as expected and the error data is available in the Error Trigger node:

So in order to further look into the problem you have described I’d need an example workflow and error flow using which this can be reproduced.

It’s worth keeping in mind the Error Trigger would not be called when manually executing the original workflow (as in this case you’d have the error right in the UI).

I don’t see response body in your screenshot…

You will not get both. You either:

  • have the node fail and then have the error workflow called (@MutedJam just showed above that it works fine). But there you will just receive the error, not the body. (if “Continue on Fail” and “Ignore Response Code” are not set)

or

  • have the node not fail, the workflow then continuing and you will get the full body (if “Ignore Response Code” is set)
1 Like