# XML header trips error

**URL:** <https://discourse.nodered.org/t/xml-header-trips-error/68154>\
**Category:** General\
**Tags:** http-request, function-node\
**Created:** [23 September 2022 20:28 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154 "2022-09-23T20:28:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [23 September 2022 20:28 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/1 "2022-09-23T20:28:43Z")

</div>

Hi there,

I have looked and have not found the answer to my problem.

Running NR (Current version: 13.4.0) inside HA, but this is not HA related.

I'm setting up the heating at my home we use Möhlenhoff Alpha units and they use a very specific xml.  
Reading is not a problem but when I wnat to submit a change the system throws a 400 error.  
After trial and error I found that the error lies in the xml header \<?xml version="1.0" encoding="UTF-8" standalone="yes"?\> I have tried 2 identical messages (with the header adjusted) and only when I use \<?xml version="1.0" encoding="UTF-8"?\> so witout the standalone="yes" bit.

I'm not that proficient yet to use function modules so I tried to following set up.

```auto
[{"id":"f9e05cfb07dc39ec","type":"inject","z":"69588d0ab0888635","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <Devices> <Device> <ID>Master1EV</ID> <HEATAREA nr=\"1\"> <T_TARGET>16</T_TARGET> </HEATAREA> </Device> </Devices>","payloadType":"str","x":430,"y":720,"wires":[["cc26578f49972747","38dc09c7d7c3b387"]]},{"id":"cc26578f49972747","type":"http request","z":"69588d0ab0888635","name":"Set Changes","method":"POST","ret":"txt","paytoqs":"ignore","url":"10.10.10.64/data/changes.xml","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/xml","valueValue":""}],"x":610,"y":740,"wires":[["fedabfc0174a3e2e"]]},{"id":"fedabfc0174a3e2e","type":"debug","z":"69588d0ab0888635","name":"This works","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":740,"wires":[]},{"id":"38dc09c7d7c3b387","type":"debug","z":"69588d0ab0888635","name":"Working XML (no \"standalone\")","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":700,"wires":[]}]

```

When I do this it's fine, but to do this I'll probably need to use a function module and just learning Java now so...(tips welcome)

So I tried the following which doesn't work due to the aforementioned " standalone ="yes" " bit

```auto
[{"id":"f1f561cc629a44e4","type":"inject","z":"69588d0ab0888635","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Devices> <Device> <ID>Master1EV</ID> <HEATAREA nr=\"1\"> <T_TARGET>16</T_TARGET> </HEATAREA> </Device> </Devices>","payloadType":"str","x":310,"y":860,"wires":[["dd6677f30c54fdda"]]},{"id":"dd6677f30c54fdda","type":"xml","z":"69588d0ab0888635","name":"","property":"payload","attr":"","chr":"","x":450,"y":860,"wires":[["80fadf8f129f6755"]]},{"id":"b37e5535aebe7b27","type":"http request","z":"69588d0ab0888635","name":"Set Changes","method":"POST","ret":"txt","paytoqs":"ignore","url":"10.10.10.64/data/changes.xml","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/xml","valueValue":""}],"x":990,"y":860,"wires":[["b4af4e6796c25110"]]},{"id":"d95da73e7a3388ad","type":"xml","z":"69588d0ab0888635","name":"","property":"payload","attr":"","chr":"","x":810,"y":860,"wires":[["b37e5535aebe7b27","42f55eb5cce496c7"]]},{"id":"80fadf8f129f6755","type":"change","z":"69588d0ab0888635","name":"","rules":[{"t":"set","p":"payload.Devices.Device[0].ID[0]","pt":"msg","to":"heat_unit","tot":"global","dc":true},{"t":"set","p":"payload.Devices.Device[0].HEATAREA[0].T_TARGET","pt":"msg","to":"kast_set_temp","tot":"global"},{"t":"set","p":"contentType","pt":"msg","to":"application/xml","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":860,"wires":[["d95da73e7a3388ad"]]},{"id":"42f55eb5cce496c7","type":"debug","z":"69588d0ab0888635","name":"Fault tripping XML due to \"standalone = \"yes\" \"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1100,"y":920,"wires":[]},{"id":"b4af4e6796c25110","type":"debug","z":"69588d0ab0888635","name":"node-red added \"standalone\"lead to error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1260,"y":860,"wires":[]}]

```

Since the Alpha has it's own Testool I uploaded both versions of the XML and it's the header that lead to faults.

So the big question is, how to get rid of just that pesky bit in the header?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [23 September 2022 20:33 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/2 "2022-09-23T20:33:40Z")

</div>

@Sandmman

give me 2 mins...

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [23 September 2022 20:37 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/3 "2022-09-23T20:37:38Z")

</div>

@Sandmman

hopefully this helps

```auto
[{"id":"b37e5535aebe7b27","type":"http request","z":"2d7bf6e3.84c97a","name":"Set Changes","method":"POST","ret":"txt","paytoqs":"ignore","url":"10.10.10.64/data/changes.xml","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/xml","valueValue":""}],"x":530,"y":820,"wires":[[]]},{"id":"a7a7881b86d11a52","type":"template","z":"2d7bf6e3.84c97a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<whatever>\n <here>{{payload}}</here>\n</whatever>","output":"str","x":320,"y":820,"wires":[["23aceca6281b0a66","b37e5535aebe7b27"]]},{"id":"0df9a687fe0f311b","type":"inject","z":"2d7bf6e3.84c97a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":820,"wires":[["a7a7881b86d11a52"]]},{"id":"23aceca6281b0a66","type":"debug","z":"2d7bf6e3.84c97a","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":420,"y":740,"wires":[]}]

```

the template node will output a `payload` - that will then be used as the BODY.  
the template node can read `msg` properties from the incoming message

---

<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:** [23 September 2022 20:54 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/4 "2022-09-23T20:54:27Z")

</div>

Or just remove the offending section.

```auto
[{"id":"5d96a3c0.0d346c","type":"xml","z":"20bb0f7f9fab47a8","name":"","property":"payload","attr":"","chr":"","x":610,"y":680,"wires":[["796c7d4b.3bb0d4"]]},{"id":"fd86b042.a9741","type":"change","z":"20bb0f7f9fab47a8","name":"","rules":[{"t":"set","p":"payload.Devices.Device[0].ID[0]","pt":"msg","to":"heat_unit","tot":"global","dc":true},{"t":"set","p":"payload.Devices.Device[0].HEATAREA[0].T_TARGET","pt":"msg","to":"kast_set_temp","tot":"global"},{"t":"set","p":"contentType","pt":"msg","to":"application/xml","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":680,"wires":[["5d96a3c0.0d346c"]]},{"id":"796c7d4b.3bb0d4","type":"change","z":"20bb0f7f9fab47a8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":" standalone=\"yes\"","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":720,"wires":[["bfa7651a.75bbb","29d82a74.ac333e"]]},{"id":"55658913.b26e98","type":"xml","z":"20bb0f7f9fab47a8","name":"","property":"payload","attr":"","chr":"","x":250,"y":680,"wires":[["fd86b042.a9741"]]},{"id":"bfa7651a.75bbb","type":"debug","z":"20bb0f7f9fab47a8","name":"Fault tripping XML due to \"standalone = \"yes\" \"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":780,"wires":[]},{"id":"29d82a74.ac333e","type":"http request","z":"20bb0f7f9fab47a8","name":"Set Changes","method":"POST","ret":"txt","paytoqs":"ignore","url":"10.10.10.64/data/changes.xml","tls":"","persist":false,"proxy":"","authType":"","x":790,"y":680,"wires":[["a2931602.9d04e"]]},{"id":"152c4274.00a4ce","type":"inject","z":"20bb0f7f9fab47a8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Devices> <Device> <ID>Master1EV</ID> <HEATAREA nr=\"1\"> <T_TARGET>16</T_TARGET> </HEATAREA> </Device> </Devices>","payloadType":"str","x":110,"y":680,"wires":[["55658913.b26e98"]]},{"id":"a2931602.9d04e","type":"debug","z":"20bb0f7f9fab47a8","name":"node-red added \"standalone\"lead to error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":680,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [23 September 2022 21:25 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/5 "2022-09-23T21:25:57Z")

</div>

Thanks, it does what I want, never even looked at the template node.... 🎉

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [23 September 2022 21:27 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/6 "2022-09-23T21:27:07Z")

</div>

This one stumped me....never considered looking at the JSON of the flow if the header would be populated there.... once again thanks! 🎈

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [23 September 2022 21:44 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/7 "2022-09-23T21:44:32Z")

</div>

Glad you got it sorted!  
The template node is an understated gem!

---

<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:** [7 October 2022 21:44 UTC](https://discourse.nodered.org/t/xml-header-trips-error/68154/8 "2022-10-07T21:44:40Z")

</div>

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