How to make http-request not encode uri?

Hi, I am using node-red to get some data from a REST-like API endpoint.
The general endpoint is like this:
some.domain.here/controller/value/signalname

filling in the values for the controller, value, and the signal has worked like expected until one of the signals has a / in the name. This predictably gives 404 as it is parsed as a part of the URL.

I tested in postman and found that when I replace the / in my signal with %2F it works. Great now I have a fix, but it does not work in node-red.

In node-red the HTTP request URL seem to be "helpful" and encodes my URL for me, and that makes my URL: some.domain.here/controller/value/signal%2Fname
into:
URL: some.domain.here/controller/value/signal%252Fname (the problem here being % is encoded for me into %25)

Is there a way to stop the http-request from doing this, or is there an alternative module I could use?
Or am I stuck having to write the http-request myself in a function block?

How exactly are you setting the url? Directly in the node? Via msg.url, or something else?

I have tried both directly, and msg.url

I also tried setting the URL as msg.rawURL and using {{{rawURL}}} in the http-request

I have created an HTTP In flow that listens for request on /test/* - so anything starting with /test/. It logs to Debug the value of msg.req.originalUrl - the actual url being sent in the request.

In a separate flow, if I enter http://localhost:1880/test/foo%2Fbar into the url field of an HTTP Request node, when I trigger it, I see the request arrive on the path /test/foo%2Fbar - so no modification appears to have happened.

I've tried a number of variations of this, and I can't get it to do the double encoding you're seeing. So there must be some aspect to this I'm missing.

Can you share an example flow that demonstrates the issue?

Also, can you confirm what version of Node-RED you're using?

I did mostly the same now to test, and it still double encodes: Test flow - pastebin

originalUrl: "/test/foo%252Fbar"

I am on version 2.0.3.

This issue was fixed in 2.0.4 :slight_smile:

  • HTTP Request: Handle partially encoded url query strings in request node

Thanks :slight_smile:
I will do an upgrade and see if that helps (which it probably will).
Edit: It did. Case closed :slight_smile:

1 Like

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