# Curl translate to httprequest

**URL:** <https://discourse.nodered.org/t/curl-translate-to-httprequest/53213>\
**Category:** General\
**Created:** [4 November 2021 13:19 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213 "2021-11-04T13:19:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ketpa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ketpa/32/42496_2.png) [@ketpa](https://discourse.nodered.org/u/ketpa)\
**Post date:** [4 November 2021 13:19 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/1 "2021-11-04T13:19:12Z")

</div>

I have curl

```auto
curl -H "Authorization: Bearer token_api_oauth" \
"https://api.smsapi.pl/sms.do?\
from=pole_nadawcy&\
to=48500000000&\
message=treść_wiadomości&\
format=json"

```

and try in node-red

 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/49b5f056b9e91090b154d282bc2e47dfc06d1b16.png)  
function  
 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c891dca55ed14f3f01302870a22966585ca5960.png)  
httprequest node  
 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a56cfd3e6012b319c571a2cebeda6aeccbb962e1.png)

whats wrong?

---

<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:** [4 November 2021 14:05 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/2 "2021-11-04T14:05:51Z")

</div>

You have set the method to POST whereas your CURL will be using GET

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [4 November 2021 14:15 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/3 "2021-11-04T14:15:56Z")

</div>

The function node is wrong, `msg.payload` should be an object with key value pairs matching the URL query arguments.

Or you can set `msg.url` and leave it blank in the http-request node. [Set the URL of a request : Node-RED](https://cookbook.nodered.org/http/set-request-url)

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [4 November 2021 15:54 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/4 "2021-11-04T15:54:13Z")

</div>

Don't know if this could help...  
[Translation-of-curl-command-to-http-request](https://discourse.nodered.org/t/translation-of-curl-command-to-http-request/52101)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [4 November 2021 16:23 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/5 "2021-11-04T16:23:46Z")

</div>

I dont know Polish .. but check this link out ..

> **[GitHub - smsapi/smsapi-javascript-client: SMSAPI javascripts client that...](https://github.com/smsapi/smsapi-javascript-client)**
>
> SMSAPI javascripts client that allows you to send messages and administrate your SMSAPI account. - GitHub - smsapi/smsapi-javascript-client: SMSAPI javascripts client that allows you to send messag...

apparently your provider has a **node.js** library that makes sending sms messages more easy

So if you read the Documentation of Node-red of how to install and setup [external libraries](https://nodered.org/docs/user-guide/writing-functions#using-the-functionexternalmodules-option) and use them in a Function node .. the rest is pretty easy according to the example on Github

```auto
const smsapi = new SMSAPI('oAuthToken');

const response = async (): Promise<MessageResponse> => {
  return await smsapi.sms.sendSms('+48605xxxxxx', 'My first message!');
};

```

ps. library found by following this [link](https://www.smsapi.pl/docs#biblioteki)

* * *

**[EDIT]** With the http requests there seems to be better better documenation and examples that i dont see with the node.js library .. so try instead this flow :

```auto
[{"id":"b5bdb3e23fbe96ca","type":"function","z":"5847b7aa62131d37","name":"","func":"// curl -H \"Authorization: Bearer token_api_oauth\" \\\n// \"https://api.smsapi.com/sms.do?\\\n// from=sender_name&\\\n// to=44123456789&\\\n// message=message_content&\\\n// format=json\"\n\nlet token_api_oauth = \"token_api_oauth\"\nlet sender_name = \"sender_name\"\nlet to_number = \"44123456789\"\nlet message_content = \"blah blah\"\n\n\nmsg.url = `https://api.smsapi.pl/sms.do?from=${sender_name}&to=${to_number}&message=${message_content}&format=json`\nmsg.method = \"GET\"\nmsg.headers = {\n \"Authorization\" : `Bearer ${token_api_oauth}`\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":920,"wires":[["7369d264e46db45e"]]},{"id":"7369d264e46db45e","type":"http request","z":"5847b7aa62131d37","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":680,"y":920,"wires":[["1afe78da8b5b1790"]]},{"id":"1afe78da8b5b1790","type":"debug","z":"5847b7aa62131d37","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":920,"wires":[]},{"id":"1be7147b87b23562","type":"inject","z":"5847b7aa62131d37","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":920,"wires":[["b5bdb3e23fbe96ca"]]}]

```

---

<div class="post-metadata">

**Author:** ![ketpa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ketpa/32/42496_2.png) [@ketpa](https://discourse.nodered.org/u/ketpa)\
**Post date:** [5 November 2021 14:42 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/6 "2021-11-05T14:42:40Z")

</div>

the problem was in header content type  
msg.headers={  
'Authorization': 'Bearer \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*',  
'content-type': 'application/x-www-form-urlencoded; charset=utf-8'

};

---

<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:** [19 November 2021 14:42 UTC](https://discourse.nodered.org/t/curl-translate-to-httprequest/53213/7 "2021-11-19T14:42:49Z")

</div>

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