# HTML tag in HTTP request

**URL:** <https://discourse.nodered.org/t/html-tag-in-http-request/43695>\
**Category:** General\
**Created:** [5 April 2021 10:09 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695 "2021-04-05T10:09:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hunter/32/60045_2.png) [@Hunter](https://discourse.nodered.org/u/Hunter)\
**Post date:** [5 April 2021 10:09 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/1 "2021-04-05T10:09:38Z")

</div>

Hello,

I'm using an HTTP request node to POST something from NR towards a NChat chatbox (SMF forum) which can contain HTML tags, such as:

```auto
index.php?message=This is <b>my</b> message. But it gets encoded into "This is &lt;b&gt;my&lt;/b&gt; message"

```

Can't figure out how to work around this. Any suggestions?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 April 2021 12:03 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/2 "2021-04-05T12:03:08Z")

</div>

I've wrapped your example as a code block to ensure the raw html gets displayed.

If you're using the URL field of the request node to inset msg.payload, you should use triple braces to prevent the html escaping: `{{{ like this }}}`.

---

<div class="post-metadata">

**Author:** ![Hunter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hunter/32/60045_2.png) [@Hunter](https://discourse.nodered.org/u/Hunter)\
**Post date:** [5 April 2021 12:22 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/3 "2021-04-05T12:22:32Z")

</div>

Sorry, thanks for wrapping up.

I'm using a function node to build the URL :

```auto
msg = {
method: 'POST',
url: 'index.php',
headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'User-Agent': 'Mozilla/5.0',
},
payload: {nchat: 'write', p2kflex: myText },
};
return msg;

```

When changing p2kflex: myText into {{{ p2kflex: myText }}} NR tells me

SyntaxError: Unexpected token '{'

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 April 2021 12:35 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/4 "2021-04-05T12:35:06Z")

</div>

> [@Hunter](#):
>
> When changing p2kflex: myText into {{{ p2kflex: myText }}} NR tells me
> 
> SyntaxError: Unexpected token '{'

Right, because that isn't valid JavaScript. As I said, the suggestion was based on the assumption you were using the URL field of the request node which supports the mustache syntax for inserting message properties.

Given that isn't the issue here, I'm not immediately sure what the fix is. Does the api docs say anything about how to submit html content?

---

<div class="post-metadata">

**Author:** ![Shubhangi](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@Shubhangi](https://discourse.nodered.org/u/Shubhangi)\
**Post date:** [27 May 2021 13:19 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/5 "2021-05-27T13:19:09Z")

</div>

Hi, I'm pretty new to node-red and wanted ask that how to GET data from http request node for using it for further calculations. And I have also used json parser for this but it is giving error. so, I have tried to minimize the data as much as i can. But, I just want the value = 2 out of the string/ Input tag for calculation. so I'm sharing these images of URL page, flow and the output with you guys. so that i can get the output i want.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e74641b60b9460c4602348527c02c49641f56ee7.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8ac8c12bf4c464f1a96e2e75f15bea27728c7926.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5ec9dc0e9772403c54be0b9fbef2d91759ada1a4.png)

````auto
[{"id":"f2caf78e.345a68","type":"function","z":"df55e200.6d814","name":"Machine 001","func":"var rowid = { payload: msg.payload[1] };\nreturn rowid;\n\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":200,"wires":[["ff907b26.328be8"]]},{"id":"4c1c89ec.ea9f58","type":"inject","z":"df55e200.6d814","name":"","props":[{"p":"payload"},{"p":"topic","v":"topic","vt":"msg"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"payload","payloadType":"msg","x":110,"y":200,"wires":[["f29a4bef.affe88"]]},{"id":"6220f2d8.c1e9dc","type":"debug","z":"df55e200.6d814","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":990,"y":280,"wires":[]},{"id":"f29a4bef.affe88","type":"http request","z":"df55e200.6d814","name":"Product Machine Mapping","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://oee.envirocom.in:1880/home/initial-setup/product-machine-mapping","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":200,"wires":[["888a4798.6e7f08"]]},{"id":"94446714.6c1078","type":"split","z":"df55e200.6d814","name":"","splt":"5","spltType":"len","arraySplt":"5","arraySpltType":"len","stream":true,"addname":"payload","x":690,"y":200,"wires":[["f2caf78e.345a68"]]},{"id":"888a4798.6e7f08","type":"html","z":"df55e200.6d814","name":"","property":"payload","outproperty":"payload","tag":"tr","ret":"html","as":"single","x":530,"y":200,"wires":[["94446714.6c1078"]]},{"id":"ff907b26.328be8","type":"html","z":"df55e200.6d814","name":"","property":"payload","outproperty":"payload","tag":"td","ret":"html","as":"single","x":450,"y":280,"wires":[["a65df3eb.d8e1d"]]},{"id":"a65df3eb.d8e1d","type":"function","z":"df55e200.6d814","name":"pieceValue","func":"var pieceValue = { payload: msg.payload[2] };\nreturn pieceValue;\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":280,"wires":[["b885a827.125ac8"]]},{"id":"b885a827.125ac8","type":"change","z":"df55e200.6d814","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"\"2\"","fromt":"str","to":"2","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"\"piecespercycle\"","fromt":"str","to":"piecespercycle","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"\"text\"","fromt":"str","to":"text","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":280,"wires":[["6220f2d8.c1e9dc"]]}]```
````

---

<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:** [27 May 2021 13:38 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/6 "2021-05-27T13:38:54Z")

</div>

The info you want is in a input tag try `tr > td > input`  
set to output an object of any attributes.  
e.g.

```auto
[{"id":"f29a4bef.affe88","type":"http request","z":"c74669a0.6a34f8","name":"Product Machine Mapping","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://oee.envirocom.in:1880/home/initial-setup/product-machine-mapping","tls":"","persist":false,"proxy":"","authType":"","x":250,"y":4080,"wires":[["888a4798.6e7f08"]]},{"id":"4c1c89ec.ea9f58","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","v":"topic","vt":"msg"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"payload","payloadType":"msg","x":250,"y":4140,"wires":[["f29a4bef.affe88"]]},{"id":"888a4798.6e7f08","type":"html","z":"c74669a0.6a34f8","name":"","property":"payload","outproperty":"payload","tag":"tr > td > input","ret":"attr","as":"single","x":510,"y":4080,"wires":[["db46be19.e35ce"]]},{"id":"db46be19.e35ce","type":"split","z":"c74669a0.6a34f8","name":"","splt":"\\n","spltType":"str","arraySplt":"8","arraySpltType":"len","stream":false,"addname":"","x":570,"y":4140,"wires":[["6220f2d8.c1e9dc"]]},{"id":"6220f2d8.c1e9dc","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":4200,"wires":[]}]

```

you can then split the array at a length of 8 and each payload will contain a row.  
All the info i used to get this I read here

> **[fb55/css-select](https://github.com/fb55/css-select#user-content-supported-selectors)**
>
> a CSS selector compiler &amp; engine. Contribute to fb55/css-select development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [27 May 2021 18:03 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/7 "2021-05-27T18:03:41Z")

</div>

Hello @Hunter ,

Did you try to encode the URI with the corresponding javascript function?

[https://www.w3schools.com/jsref/jsref\_encodeURI.asp](https://www.w3schools.com/jsref/jsref_encodeURI.asp)

Cheers  
Ranki

---

<div class="post-metadata">

**Author:** ![Shubhangi](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@Shubhangi](https://discourse.nodered.org/u/Shubhangi)\
**Post date:** [29 May 2021 11:23 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/8 "2021-05-29T11:23:56Z")

</div>

Thank you so much, you solved my one of the major problems Thank you again.

---

<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:** [12 June 2021 11:23 UTC](https://discourse.nodered.org/t/html-tag-in-http-request/43695/9 "2021-06-12T11:23:59Z")

</div>

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