# Curl Request with XML Payload

**URL:** <https://discourse.nodered.org/t/curl-request-with-xml-payload/30620>\
**Category:** General\
**Created:** [23 July 2020 16:36 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620 "2020-07-23T16:36:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [23 July 2020 16:36 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/1 "2020-07-23T16:36:21Z")

</div>

Hello,

have request that worls from terminal

```auto
curl -k --anyauth -u "test:testpass1" \
     "http://${FB}/upnp/control/x_voip" \
     -H 'Content-Type: text/xml; charset="utf-8"' \
     -H 'SoapAction: urn:dslforum-org:service:X_VoIP:1#X_AVM-DE_DialNumber' \
     -d '<?xml version="1.0" encoding="utf-8"?>
         <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                     xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <s:Body>
               <u:X_AVM-DE_DialNumber xmlns:u="urn:dslforum-org:service:X_VoIP:1">
                 <NewX_AVM-DE_PhoneNumber>'**610'</NewX_AVM-DE_PhoneNumber>
               </u:X_AVM-DE_DialNumber>
            </s:Body>
         </s:Envelope>'

```

But how could i execute it from NR?

Thanks a lot!

---

<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:** [23 July 2020 17:19 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/2 "2020-07-23T17:19:08Z")

</div>

What have you tried? what are you getting back? (post screenshots of flow/error/debug results)

I should simply be a case of...

A trigger (e.g. inject node) ➡  
change or function node (set `msg.headers` to `{ "Content-Type" : "text/xml; charset='utf-8'", "SoapAction" : "urn:dslforum-org:service:X_VoIP:1#X_AVM-DE_DialNumber"}` ➡  
http request ➡  
XML (convert XML to JS object) ➡  
debug

See the [cookbook](https://cookbook.nodered.org/#http-requests)

---

<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:** [23 July 2020 17:32 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/3 "2020-07-23T17:32:13Z")

</div>

Here is a working example based on [this](https://www.krengeltech.com/2017/05/tutorial-using-postman-to-test-xml-web-services/)...

flow...

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

result...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d5408dcb93ad884493daa71de77a402817f13e7.png)

export of the flow i used

```auto
[{"id":"6e215f49.aadfe","type":"inject","z":"68fd4d54.10dd54","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":400,"wires":[["261bcfb3.22dac"]]},{"id":"261bcfb3.22dac","type":"change","z":"68fd4d54.10dd54","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers['SOAPAction']","pt":"msg","to":"https://www.w3schools.com/xml/FahrenheitToCelsius","tot":"str"},{"t":"set","p":"headers['Content-Type']","pt":"msg","to":"text/xml","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <FahrenheitToCelsius xmlns=\"https://www.w3schools.com/xml/\"> <Fahrenheit>100</Fahrenheit> </FahrenheitToCelsius> </soap:Body> </soap:Envelope>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":400,"wires":[["2bd2ae1f.24ec22"]]},{"id":"2bd2ae1f.24ec22","type":"http request","z":"68fd4d54.10dd54","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://www.w3schools.com/xml/tempconvert.asmx","tls":"","persist":false,"proxy":"","authType":"","x":610,"y":400,"wires":[["543921d8.c6caa"]]},{"id":"41fb1ba0.9393f4","type":"debug","z":"68fd4d54.10dd54","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":400,"wires":[]},{"id":"543921d8.c6caa","type":"xml","z":"68fd4d54.10dd54","name":"","property":"payload","attr":"","chr":"","x":770,"y":400,"wires":[["41fb1ba0.9393f4"]]},{"id":"1ca55c6.5df13a4","type":"comment","z":"68fd4d54.10dd54","name":"Send 100 deg Fahrenheit to tempconvert.asmx for conversion to Celcius (SOAP POST, XML Result)","info":"","x":540,"y":360,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [24 July 2020 09:07 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/4 "2020-07-24T09:07:52Z")

</div>

Thanks a lot for solution!  
I have made it much easier.  
It is the example how make a call from Fritzbox with Dial-Helper.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43af7dbb6829607320f751da4cee12f6cd3470b1.png)

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

```auto

[
    {
        "id": "5f81fd16.62a104",
        "type": "template",
        "z": "1bba2fd9.957c9",
        "name": "Make Call Fritzbox",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": " curl -k --anyauth -u \"login:password\" \\\n \"http://fritz.box:49000/upnp/control/x_voip\" \\\n -H 'Content-Type: text/xml; charset=\"utf-8\"' \\\n -H 'SoapAction: urn:dslforum-org:service:X_VoIP:1#X_AVM-DE_DialNumber' \\\n -d '<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <s:Body>\n <u:X_AVM-DE_DialNumber xmlns:u=\"urn:dslforum-org:service:X_VoIP:1\">\n <NewX_AVM-DE_PhoneNumber>'32536'</NewX_AVM-DE_PhoneNumber>\n </u:X_AVM-DE_DialNumber>\n </s:Body>\n </s:Envelope>'",
        "output": "str",
        "x": 300,
        "y": 1635,
        "wires": [
            [
                "14bfe930.3b2627"
            ]
        ]
    },
    {
        "id": "14bfe930.3b2627",
        "type": "exec",
        "z": "1bba2fd9.957c9",
        "command": "",
        "addpay": true,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "",
        "x": 455,
        "y": 1635,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "5b05c621.1ce938",
        "type": "inject",
        "z": "1bba2fd9.957c9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 1635,
        "wires": [
            [
                "5f81fd16.62a104"
            ]
        ]
    },
    {
        "id": "976485b2.25b658",
        "type": "comment",
        "z": "1bba2fd9.957c9",
        "name": "Make Fritz!Box Call to Headset",
        "info": "",
        "x": 190,
        "y": 1590,
        "wires": []
    }
]

```

Maybe someone can use it

---

<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:** [24 July 2020 09:25 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/5 "2020-07-24T09:25:23Z")

</div>

Not sure many people would agree it is easier.

Obviously I could have suggested the exec node but that's not really the node-red way (it's a stop gap for missing functionality (my opinion))

IMO, spawning commands from exec node is the LAST place to go if a native solution already exists (like the one I gave you)

Each to their own.

---

<div class="post-metadata">

**Author:** ![ThisisIO](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@ThisisIO](https://discourse.nodered.org/u/ThisisIO)\
**Post date:** [24 July 2020 09:42 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/6 "2020-07-24T09:42:18Z")

</div>

> [@Steve-Mcl](#):
>
> Not sure many people would agree it is easier.

Maybe you right. At least one more solution 🙂

---

<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:** [22 September 2020 09:42 UTC](https://discourse.nodered.org/t/curl-request-with-xml-payload/30620/7 "2020-09-22T09:42:26Z")

</div>

Closed on 22 September 2020 09:42 UTC

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