HTTP Post code conversion

In first words I would like to say Hi and inform that I am completely beginner in NodeRed, so far have done basics, but now stuck with something what might be a joke.

I would like to configure NodeRed to send SMS messages with notifications. SMS Gateway Provider (PL) share API that looks like this example:

curl -X GET -G \
'https://api2.smsXXXX.pl/sms' \
-d key=klucz \
-d password=haslo \
-d from=TEST \
-d to=600111222 \
-d msg=Wiadomosc

How should I convert this to be compatible with http post node?

GET means that the passed perameters will be URL parameters. The resulting full URL looks like:

https://api2.smsXXXX.pl/sms?key=klucz&password=haslo...

To use this in the request node, assuming you want to pass variable data into the parameter values, you can use Mustache style formatting on the URL property of the request node:

https://api2.smsXXXX.pl/sms?key={{{mykey}}}&password={{{mypassword}}}...

Where your inbound msg would be something like:

{
    mykey: 'klucz',
    mypassword: 'haslo',
    ...
}
1 Like

Or set the url in the http request node to
https://api2.smsXXXX.pl/sms.
Select append msg.payload as query string
Then sending a msg.payload like

{
    key: 'klucz',
    password: 'haslo'
}

The query sent would be
https://api2.smsXXXX.pl/sms?key=klucz&password=haslo
Adding other msg.payload properties and they will be appended to the query string also.

3 Likes

Thank you very much for all advices. Most important thing was how to convert that shell to url line. I have done as you suggested and it works!
I even not planned to use variables, but with your suggestion it makes my “logic” more simple.

Thank you once again!

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