Curl Request with XML Payload

Hello,

have request that worls from terminal

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!

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) :arrow_right:
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"} :arrow_right:
http request :arrow_right:
XML (convert XML to JS object) :arrow_right:
debug

See the cookbook

Here is a working example based on this...

flow...

result...
image

export of the flow i used

[{"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":[]}]
2 Likes

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


[
    {
        "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

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.

Maybe you right. At least one more solution :slightly_smiling_face:

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