Problem with HTTP Request POST

Describe the issue/error/question

  • when trying to make a POST with the node “HTTP REQUEST” the URL seems to be manipulated and seems to be wrongly manipulated.

Any advice or suggestion?
Below are the details of the problem:

What is the error message (if any)?

  • Look to this configuration: note that the URL contains a domain in the format and in the error message it says that the url is something else than what is in the config "message": "404 - {"message":"Not Found","url":"/api/v1/company-units?/api/v1/company-units&","code":404}",

Please share the workflow

  • here is the problematic node

Information on your n8n setup

  • n8n version: 0.177.0
  • Database you’re using: postgresql
  • **Running n8n via Docker

Hey @reichert, it seems you are using an expression of {{$node["Configurações iniciais"].json["create_unit_url"]}} in your HTTP Request node. Are you by any chance passing on multiple different items to your HTTP Request node?

If so, you might be missing an $item(0) somewhere if you have multiple items but only one URL (like {{ $item(0).$node["Configurações iniciais"].json["create_unit_url"] }} for example).

Hi MutedJam, sorry for the delay.

Actually, even if I put the same value that is in the initial SET node (Configurações Iniciais) as fixed by means of not using an expression, the error is the same, so it is not an expression problem.

Here is the full workflow:

and here is the error wich is returning with the malformed url in the error message:

Hey @reichert, many thanks for sharing your workflow!

From testing this it seems the URL you are calling returns a 404 error, even outside of n8n:

The misleading error message is also coming from the site you are calling as shown in the screenshot above. You can reproduce this using curl for example:

curl --request POST \
  --url \
  --header 'Authorization: Bearer foo' \
  --header 'Content-Type: application/json' \
  --header 'accept: application/json,text/*;q=0.99' \
  --header 'user-agent: axios/0.21.4' \
  --data '{
	"name": "foo",
	"code": "foo",
	"use_information_in_survey": 1,
	"country_id": 1

So you might want to check with the support team or community how exactly the request should look like.

Once that’s sorted you’d still need to update your expression used in the Authorization header of your HTTP Request though. It’s currently set to Bearer {{$node["authentication"].json["result"]["access_token"]}}, meaning it would only work for the first item as per my previous message.

Hope this helps and clarifies!

Hi @MutedJam
Sorry for this begginer question and thanks for taking your time to make a CURL request :slight_smile:

In fact the error message confused me and I should have tested the endpoint.
May I suggest to fix/improve this error message when the HTTP Request does not return an HTTP 200 code?

My suggestion would be to print something like:
The server answered:
HTTP Code: 404
Response: whatever the server send back


Gey @reichert, not a beginner question at all. This error message definitely threw me off big time as well I was pretty convinced this was a bug (until I got the same error outside n8n).

The page uses a very similar error format to n8n as well, so that’s why you have a message field inside a message field (one message from wehelpsoftware, one from n8n). For many other APIs it’s less ambiguous which part comes from n8n and which is from the API itself.

That said, I do believe there are plans for a version 2 of the HTTP Request node. Perhaps @Nivb_6 already knows more on whether an updated error handling (like what you have in mind) will be part of that version?