# Variable in HTTP GET URL makes the response wrong

**URL:** <https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770>\
**Category:** General\
**Created:** [6 December 2022 14:28 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770 "2022-12-06T14:28:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [6 December 2022 14:28 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/1 "2022-12-06T14:28:08Z")

</div>

Really bad title of the post but I don't know how else to explain it 😅

I have been using variables in the URL field of my HTTP Request nodes for months without issue, but today I tried something new.

I am pulling a PDF from an API, and returning the result as a binary buffer for further processing.  
If I write the full URL to the file in the URL field, I get the correct binary buffer back.

But if I substitute the last part of the URL with a variable, I get the wrong buffer back and the file becomes corrupt when saving it.

Example of full URL:  
`https://example.com/files/invoice.pdf`

Example of URL with variable:  
`https://example.com/files/{{filename}}`

`msg.filename` is of course set to `invoice.pdf`

Anyone know why this is happening?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 December 2022 14:44 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/2 "2022-12-06T14:44:55Z")

</div>

Can you show us the info properties for the HTTP Request

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9b483adcd0a3554d83de8ab3e87f5b6a397a42e6.png)

also, export the problematic flow (just the inject and http node)

---

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [6 December 2022 16:18 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/3 "2022-12-06T16:18:25Z")

</div>

> [@Steve-Mcl](#):
>
> Can you show us the info properties for the HTTP Request

 ![66](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57424f22f5af0bcf88cfde025064964abe8d42a5.png)

> [@Steve-Mcl](#):
>
> also, export the problematic flow (just the inject and http node)

I don't really want the public to see parts of this flow, but I guess I can DM it to you?

---

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [7 December 2022 11:07 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/4 "2022-12-07T11:07:29Z")

</div>

Anyone else know why this is happening?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 December 2022 13:21 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/5 "2022-12-07T13:21:07Z")

</div>

Not enough info to say for sure, I would suspect the msg.filename has more than just invoice.pdf in it. Show us a debug of message going into http request node.

---

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [7 December 2022 13:41 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/6 "2022-12-07T13:41:34Z")

</div>

Yes it does, it has slashes.

 ![Skjermbilde](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4caf5f012a1a3210d400eb4fe33221c4fc8bb8c2.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 December 2022 13:58 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/7 "2022-12-07T13:58:36Z")

</div>

Your url varies with every post, very confusing  
From your image filename has a / in it using {{ }} will convert it to &#x2F; . Try using {{{ }}}

---

<div class="post-metadata">

**Author:** ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Post date:** [7 December 2022 14:12 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/8 "2022-12-07T14:12:37Z")

</div>

The URL is different because there's two different HTTP nodes in the flow.

But `{{{ }}}` did the trick, thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 December 2022 14:13 UTC](https://discourse.nodered.org/t/variable-in-http-get-url-makes-the-response-wrong/71770/9 "2022-12-21T14:13:27Z")

</div>

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