HTTP Request Status Rejected 502

I am trying to use the HTTP request node to get access token, but I am getting this error. When I tried with Postman it worked. Any solution to this? Thanks

{
"status": "rejected",
"reason": {
"message": "Request failed with status code 502",
"name": "Error",
"stack": "Error: Request failed with status code 502 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 (events.js:327:22) at endReadableNT (internal/streams/readable.js:1327:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)"
}
}

Hi @zocket, this would suggest the request made by Postman doesn’t 100% match the one made by the HTTP Request node.

Could you share the documentation of the API you are requesting a token from? We might be able to sort this out :slight_smile:

It was working before very well, but the issues started today

The issue was with Snov io API for requesting access token

Oh, you mean it was working in n8n before yesterday? Did you upgrade your version or change anything else (if so, can you confirm what changes exactly you have made)?

Okay, I can reproduce the problem - when testing the below workflow I am running into the problem you have described:

Example Workflow

It is working fine though when using N8N_USE_DEPRECATED_REQUEST_LIB=true suggesting this is caused by the axios library used by default:

So to make this work you probably want to set the aforementioned environment variable for now.

Thanks, How can that be done in n8n cloud version?

Sorry, I didn’t realize you were using the cloud version. I did some additional testing in the meantime and it seems I blamed axios too early.

It seems the API simply doesn’t like the default user-agent header for whatever reason and responds with the non-helpful error we both have encountered. As soon as I was manually setting a different user-agent header, the request is working fine.

So you can probably solve it for your account as well (tested this on cloud v0.148.0) simply by adding this header to your HTTP Request node, for example:

image

Thanks, this worked. I appreciate

1 Like

Hi, the access token works. But today an issue arised on the second node that uses AccessToken. It was giving this error on the cloud version. I am using email finder API request

 {
"error": {
"message": "Request failed with status code 400",
"name": "Error",
"stack": "Error: Request failed with status code 400 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 (events.js:327:22) at IncomingMessage.EventEmitter.emit (domain.js:467:12) at endReadableNT (internal/streams/readable.js:1327:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)"
}
}

I am using version 0.144.0

Hi @MutedJam

Any solution to this problem am currently facing? Thanks

Hi @zocket, I am not familiar with this API and currently don’t have a lot of time for extensive testing. A 400 error suggests you are sending a request the server considers invalid.

So it would be great if you could help by providing a reproducible example workflow leading to the error you are facing as well as a link to the documentation of the respective API.

Hi @zocket, to follow up on this, is this the API endpoint you are having issues with? This is working fine for me when I tried this on n8n.cloud (where access_token is provided by the previous node):

Example Workflow

So I’d definitely need an example from you to reproduce and understand the error you are seeing.

Hi @MutedJam Thanks, this helped. I appreciate your support!

1 Like