Make a curl with post or oder

Hello
This is a command from gsm modem to send SMS.
How can I run the following command in node red? And of course send the phone number and text of the SMS out of the variable?
thank you

curl 'http://192.168.8.1/api/sms/send-sms'
-H 'Connection: keep-alive'
-H 'Pragma: no-cache'
-H 'Cache-Control: no-cache'
-H 'Accept: /'
-H 'X-Requested-With: XMLHttpRequest'
-H '__RequestVerificationToken: 1743643931'
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
-H 'Origin: 192.168.8.1'
-H 'Referer: 192.168.8.1/html/smsinbox.html'
-H 'Accept-Language: fa-US,fa;q=0.9,en-US;q=0.8,en;q=0.7'
-H 'dnt: 1'
--data-raw '<?xml version="1.0" encoding="UTF-8"?>-1+239133311838text message sms1512021-07-16 18:19:51'
--compressed
--insecure

Have you looked at the (very good) documentation of the http request node?
Doing what you want is fairly obvious once you have looked at the manual.

1 Like

Also are you 100% sure all that is required, I'll bet most of the headers aren't especially

-H 'Connection: keep-alive'
-H 'Pragma: no-cache'
-H 'Cache-Control: no-cache'
-H 'X-Requested-With: XMLHttpRequest'
-H 'Accept-Language: fa-US,fa;q=0.9,en-US;q=0.8,en;q=0.7'

Unfortunately I'm not a programmer and I use node red for my simple tasks, I also extracted these commands from the Google Chrome output.
Please give me a sample flow to run the above program if possible. Thank you

Please read the doc that @greengolfer pointed at and try, if you get stuck post whay you've tried and we'll help you fix it.

https://cookbook.nodered.org/#http-requests

It is customary on this kind of forum to try first and then ask for help and not saying please, can you do this for me...

Using the documentation, you can figure out that you have to put the url in msg.url, the headers in msg.headers and so on. Either with a change node or a function node something like:

msg.url = "http://192.168.8.1/api/sms/send-sms";
msg.method = "GET";
msg.headers = {
    'Origin': '192.168.8.1'
    'Referer': '192.168.8.1/html/smsinbox.html'
} ;

And so on.

2 Likes

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