Error 401 when http auth via cookie

I’m having trouble authenticating to a REST API (S-MAX). In an initial request, I retrieve a token via HTTP post. This token must now be sent as a cookie in the format SMAX_AUTH_TOKEN=abcdefg.. for the actual API query. This works in Postman, but I get a 401 error in n8n. I’ve implemented the instructions in the documentation (https_://docs.microfocus.com/doc/423/2021.05/connecttorestapi). The request looks like this:

{ “headers”:
{ “cookie”: “**hidden**”, // “SMAX_AUTH_TOKEN=abcdefg..”
“accept”: “*/*”,
“user-agent”: “Apache-HttpClient/4.1”,
“accept-encoding”: “gzip, deflate, br”,
“content-type”: “application/json” },
“method”: “GET”,
“uri”: “https://dev.smax-hosting.de/rest/123456/ems/Device/123456”,
“gzip”: true,
“rejectUnauthorized”: true,
“followRedirect”: true,
“resolveWithFullResponse”: true,
“followAllRedirects”: true,
“maxRedirects”: 21,
“timeout”: 300000,
“qs”: { “layout”: “FULL_LAYOUT”, “TENANTID”: “123456” },
“encoding”: null,
“json”: false,
“useStream”: true
}

What am I doing wrong?

i’m using n8n Community Edition Version 1.112.4

Hey @rka,

Could you please share your workflow? Just select the relevant nodes (or whole workflow is fine too), press Ctrl+C, and paste the JSON data here. Be sure to remove or hide any sensitive values like tokens or credentials before you paste it.

Try disable this lowercase headers in your API Call mit Cookie node

Thanks cutecatcode, the solution is much simpler, and I only noticed it after anonymizing the JSON. The second call only shows “https://dev.”, but it should be “https://development.”, like the login. Sometimes you just can’t see the forest for the trees :wink:

1 Like

Ah hahahah, ain’t see that too.

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