Work flow Execution for 2 HTTP requests

HI,
I have a total of 2 HTTP requests. One for the Login and the other for getting user data after login.

The First HTTP request is successful and returns a token.
In the Second HTTP request I am saving the token in the headers like

Headers: {
authorization : Bearer {{$node[“HTTP Request”].data[“token”]}}
}
which is showing my token when I give the expression like

Headers : {
authorization: Bearer eyJhbGciOiJIUzI1NiIsI…
}
But when I execute the work flow it is not executing and showing something like “Workflow Execution Crashed

When I execute only the second node it is giving me response.

Is there any thing wrong which I am doing or any changes which I have to do?

Here is My workfllow code

    {
  "name": "Testing",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://localhost:8000/api/user/login",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "{\n\"email\":\"[email protected]\",\n\"password\":\"Password@123\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        500,
        310
      ],
      "alwaysOutputData": true,
      "retryOnFail": true
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http://localhost:8000/api/user/",
        "allowUnauthorizedCerts": true,
        "options": {
          "timeout": "=2000"
        },
        "bodyParametersUi": {
          "parameter": []
        },
        "headerParametersUi": {
          "parameter": [
            {
              "name": "=authorization",
              "value": "=Bearer {{$node[\"HTTP Request\"].data[\"token\"]}}"
            }
          ]
        }
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1200,
        310
      ],
      "alwaysOutputData": true,
      "retryOnFail": true
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "1"
}

It got executed now. I don’t know the exact reason why the previous error was occured but previously I have some nodes like set and other nodes which access another Database now I have removed them.

Thank you

I am glad that you were able to solve your issue. Have fun!

1 Like