Help with the HTTP request node

I need to send a request, containing '<' and '>' as content, to a webhook.
Using webhook.site, I can see, that there are many '%3C' and '%3E's in the url while in debug panel it shows the original term. Here's an example:

https://webhook.site/330debe9-0f95-4805-a766-09cace553fcb?login=login_dl&password=password&type=import&really=1&content={<active_item/><new_item/><stationname.short>apiKeyPROTO</stationname.short><message><item.artist>testArtist</item.artist>+-+<item.title>meTitle</item.title></message>}

while webhook.site shows:

https://webhook.site/330debe9-0f95-4805-a766-09cace553fcb?login=login_dl&password=password&type=import&really=1&content={%3Cactive_item/%3E%3Cnew_item/%3E%3Cstationname.short%3EapiKeyPROTO%3C/stationname.short%3E%3Cmessage%3E%3Citem.artist%3EtestArtist%3C/item.artist%3E+-+%3Citem.title%3EmeTitle%3C/item.title%3E%3C/message%3E}

But this seems to be a problem for the target webhook...

Does anybody have an idea?
Thanks a lot!
Florian

You could try something like this in a function node (untested as not near my PC)...

msg.url = "https://webhook.site/330debe9-0f95-4805-a766-09cace553fcb";

msg.payload = {
    login: "login_dl",
    password: "password",
    type: "import",
    really: 1,
    content: `<active_item/><new_item/><stationname.short>apiKeyPROTO</stationname.short><message><item.artist>testArtist</item.artist>+-+<item.title>meTitle</item.title></message>`
};

return msg;

Thanks Dave,

but sorry, my fault: it's a GET request, so no payload inside...

Can you post a simple flow showing the problem? Preferably just an Inject node and the http node, so we can see exactly what you are doing.

You can set the http request node to append the payload query strings, in a get request
payload - Append to query-string parameters

Or use a template node to construct the URL using {{{ }}} to ignore html parsing of input variable. Read the sidebar help section.

[
    {
        "id": "b9f5087df343d410",
        "type": "group",
        "z": "be78e41b9d95865c",
        "name": "DLplus A-T",
        "style": {
            "label": true
        },
        "nodes": [
            "b19c8858b209f8ee",
            "79de4164e7fd70c7",
            "b6bfbdb005e8affd",
            "8b1c012c8a8489fd"
        ],
        "x": 54,
        "y": 1139,
        "w": 952,
        "h": 82
    },
    {
        "id": "b19c8858b209f8ee",
        "type": "inject",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "Trigger",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 1180,
        "wires": [
            [
                "79de4164e7fd70c7"
            ]
        ],
        "icon": "font-awesome/fa-mouse-pointer"
    },
    {
        "id": "79de4164e7fd70c7",
        "type": "function",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "create DLplus A-T",
        "func": "let Data = {\n    DlUrl: `https://webhook.site/88f91c09-92d7-44f0-ac91-86f78b2cd771`,\n    login: `Login`,\n    password: `pass`,\n    station: `stationName`    \n};\nlet trackArtistPlus = `theArtist`;\nlet trackTitlePlus = `theTitle`;\nlet DLplusUrl = `${Data.DlUrl}?login=${Data.login}&password=${Data.password}&type=import&really=1&content={<active_item/><new_item/><stationname.short>${Data.station}</stationname.short><message><item.artist>${trackArtistPlus}</item.artist>+-+<item.title>${trackTitlePlus}</item.title></message>}`;\nDLplus = {url: DLplusUrl};\nDLplus.rejectUnauthorized = false;\nDLplus.type = \"DLplus (GET)\"; // Info only...\nDLplus.method = \"GET\";\n\nreturn DLplus;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 1180,
        "wires": [
            [
                "8b1c012c8a8489fd"
            ]
        ]
    },
    {
        "id": "b6bfbdb005e8affd",
        "type": "debug",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "show DLplus Answer",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 1180,
        "wires": []
    },
    {
        "id": "8b1c012c8a8489fd",
        "type": "http request",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "",
        "method": "use",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 610,
        "y": 1180,
        "wires": [
            [
                "b6bfbdb005e8affd"
            ]
        ]
    }
]

Hm... Tried
{{{url}}}
in the URL field, but it outputs the same...

And I can't find how to Append to query-string parameters. Do you have a few further hints for me? (the "Disable strict HTTP parsing" option doesn't change anything)

Set the http node to get, not by method, then it is available as a dropdown.

can you show us msg.req after the http request node?

When sharing code, this is the best (and only) way to do it so that people can help you. An image just shows the Node Blocks and not what they contain.

Thanks! Since I always try to get everything controlled by function nodes...

The node seems not do accept the payload...

That's what I did... :thinking:

Did you switch to the Toggle Flows/Source option in the lower right corner?

(the { } symbol)

Here's what I tried:

[
    {
        "id": "b9f5087df343d410",
        "type": "group",
        "z": "be78e41b9d95865c",
        "name": "DLplus A-T",
        "style": {
            "label": true
        },
        "nodes": [
            "b19c8858b209f8ee",
            "79de4164e7fd70c7",
            "b6bfbdb005e8affd",
            "8b1c012c8a8489fd",
            "a584144af6540ef9"
        ],
        "x": 54,
        "y": 1139,
        "w": 952,
        "h": 122
    },
    {
        "id": "b19c8858b209f8ee",
        "type": "inject",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "Trigger",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 1220,
        "wires": [
            [
                "79de4164e7fd70c7"
            ]
        ],
        "icon": "font-awesome/fa-mouse-pointer"
    },
    {
        "id": "79de4164e7fd70c7",
        "type": "function",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "create DLplus A-T",
        "func": "let Data = {\n    DlUrl: `https://webhook.site/88f91c09-92d7-44f0-ac91-86f78b2cd771`,\n    login: `Login`,\n    password: `pass`,\n    station: `stationName`    \n};\nlet trackArtistPlus = `theArtist`;\nlet trackTitlePlus = `theTitle`;\nDLplus = {url: Data.DlUrl};\nDLplus.payload = `login=${Data.login}&password=${Data.password}&type=import&really=1&content={<active_item/><new_item/><stationname.short>${Data.station}</stationname.short><message><item.artist>${trackArtistPlus}</item.artist>+-+<item.title>${trackTitlePlus}</item.title></message>}`;\nDLplus.rejectUnauthorized = false;\nDLplus.type = \"DLplus (GET)\"; // Info only...\n\nreturn DLplus;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 1220,
        "wires": [
            [
                "8b1c012c8a8489fd",
                "a584144af6540ef9"
            ]
        ]
    },
    {
        "id": "b6bfbdb005e8affd",
        "type": "debug",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "show DLplus Answer",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 1220,
        "wires": []
    },
    {
        "id": "8b1c012c8a8489fd",
        "type": "http request",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "query",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": true,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 610,
        "y": 1220,
        "wires": [
            [
                "b6bfbdb005e8affd"
            ]
        ]
    },
    {
        "id": "a584144af6540ef9",
        "type": "debug",
        "z": "be78e41b9d95865c",
        "g": "b9f5087df343d410",
        "name": "payload",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 1180,
        "wires": []
    }
]

But I get an "invalid payload" message from the request node. Does it expect a different format?

No, I didn’t, because I thought the boxes at the bottom were part of the image. (I must read up on these features it this is new!) But then, selfishly, I need to do another action and download a file to my computer, before I can begin to help,

Try putting it in the payload property as @dynamicdave described here

You can click the Copy Flow to Clipboard button (second from the left).

1 Like

Okay, so I can do both! :wink:
First, that's the payload:


And now it accepts the payload (only a few steps later...), but the answer (and also the input shown on the webhook.site panel) keeps the same.

Here's webhook's answer (formatted as code because the editor interpreted a couple of the problems itself...):

responseUrl: "https://webhook.site/88f91c09-92d7-44f0-ac91-86f78b2cd771?login=login_dl&password=password&type=import&really=1&content=%3Cactive_item%2F%3E%3Cnew_item%2F%3E%3Cstationname.short%3EapiKeyPROTO%3C%2Fstationname.short%3E%3Cmessage%3E%3Citem.artist%3EtestArtist%3C%2Fitem.artist%3E%2B-%2B%3Citem.title%3EmeTitle%3C%2Fitem.title%3E%3C%2Fmessage%3E"

Seems to be kind of a limitation/speciality of the used 'get' library?

What is returned if you paste the url in the browser?

As to me it looks like the webook site is not accepting a properly formated and encoded url query string.

Its behaviour is similar to the webhook that I have to send my data to.

The interesting thing is, that the software that I want to replace uses an engine (maybe) from or at least like mozilla, and the webhook interprets the content correct. So my guess is that I have to try to get the same result until my piece of software will work as expected.

When I paste the url into Safari, it will get "corrected" the wrong way.

Well, without any help from the other side (of the desired webhook), I think I have to cancel this "project" because it seems to me not clear enough, if that is the true problem...
And on the other side it would be interesting, if I could find a solution on this behaviour...

Thanks for your help!