Value from previous step appearing as 'null'

Describe the issue/error/question

I have a workflow and in the second step I make a HTTP request to get a credential (serviceTicket).

I use this serviceTicket in several of the next steps in the flow to make further HTTP calls. This works in the first HTTP call (the third step in the flow, which receives the value directly from the second step - so I can access it simply with $json[“serviceTicket”]).

However, after doing some other steps I go to make another HTTP request. To access the serviceTicket from the second step I use the expression provided when I drag and drop the value from the input on the left of the screen in to the value field for the node:

This gives me an authorization failed error which confused me for a while. I tested by copying and pasting the value in as a fixed value instead and that resolved the problem. But when I go back to using an expression (because the value is dynamic, changing every time the workflow starts) it doesn’t work, despite it initially showing the correct value as “Result for Item 1” as below:

n8n serviceticket problem2

I did notice that when I change the “Input” dropdown on the top left of the editor the “Result for Item 1” value displays as null. I am confused by this as I thought the $node[“Node Name”] expression should retrieve the value from that specific step. But it would explain why authentication is failing if it’s not reading a value.

When I change the “Input” dropdown back to the immediately preceeding step, the expression does show the correct value instead of null, but I still get an Authorization failed error.

Can anyone help me out with why this might not be working? To be clear, if I copy and paste the serviceTicket as a fixed value, the flow works. But using an expression to load it dynamically, regardless of other settings, I cannot get working at all.

What is the error message (if any)?

ERROR: Authorization failed - please check your credentials


{
"status":
"rejected",
"reason":
{
"message":
"401 - "{\"message\":\"Current session has timed out.\",\"errorCode\":201,\"errorType\":\"No active session\"}"",
"name":
"Error",
"stack":
"Error: 401 - "{\"message\":\"Current session has timed out.\",\"errorCode\":201,\"errorType\":\"No active session\"}" at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11) at IncomingMessage.emit (node:events:525:35) at IncomingMessage.emit (node:domain:489:12) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)"
}
}

Please share the workflow

Information on your n8n setup

  • n8n version: Latest version from Azure AKS installation guide
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]: not sure what this means?
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Azure AKS

I have figured out my own problem - I hope this reply helps others in future.

It turns out that using

$node["Previous Step Name"]

doesn’t seem to work, even though that’s what is populated when you drag and drop.

I managed to fix this issue by changing the expression to this instead:

{{ $("Execute VSZ Service Ticket Get").item.json.serviceTicket }}