# Specific CURL command in HTTP-REQUEST node

**URL:** https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776
**Category:** General
**Created:** [12 November 2020 01:01 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776 "2020-11-12T01:01:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![muntasirjoarder](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@muntasirjoarder](https://discourse.nodered.org/u/muntasirjoarder)
#### Post date: [12 November 2020 01:01 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776/1 "2020-11-12T01:01:43Z")

</div>

Hi

I want to implement the following CURL command in a simple HTTP node-red node. How can I do that?

curl -k -d "grant\_type=client\_credentials" -H "Authorization: Basic Zlp2NXJYRZ4T3dQc1dkM0lzREhhWEdzYTpLZHlTbmFiZl8wQldqR3ozQjYxREcxQ01lUW9p, Content-Type: application/x-www-form-urlencoded" [https://eco-counter-tools.com/token](https://eco-counter-tools.com/token)

I created a Function node like as follows and then connected with HTTP-Request node:

var key ="key string";  
var secret = "secret string";  
var concatenated = key+":"+secret;  
var hash = (new Buffer(concatenated)).toString('base64');

msg.method ='POST';  
msg.url = "[https://eco-counter-tools.com/token](https://eco-counter-tools.com/token)";  
msg.headers = {};  
msg.headers['Authorization'] = 'Basic '+hash;  
msg.headers['Content-Type'] = 'application/x-www-form-urlencoded';  
msg.payload = "grant\_type=client\_credentials";  
return msg;

But I got 403 error (No matching resource found in the API for the given request). What did I do wrong?

---

<div class="post-metadata">

### Author: ![muntasirjoarder](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@muntasirjoarder](https://discourse.nodered.org/u/muntasirjoarder)
#### Post date: [12 November 2020 01:17 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776/2 "2020-11-12T01:17:41Z")

</div>

The above hash and URL are not the actual ones. I modified them for security reason.

---

<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: [12 November 2020 08:14 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776/3 "2020-11-12T08:14:11Z")

</div>

> [@muntasirjoarder](#):
>
> But I got 403 error

Error 403 is normally "forbidden"

Did you get the token correct?

Try putting `node.warn(hash)` after `var hash = ...` and compare the hash to your working curl.

---

<div class="post-metadata">

### Author: ![muntasirjoarder](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@muntasirjoarder](https://discourse.nodered.org/u/muntasirjoarder)
#### Post date: [13 November 2020 00:00 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776/4 "2020-11-13T00:00:49Z")

</div>

Yes the hash is correct. In fact I hard-coded the hash and tried. But still got the same 403.

---

<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: [12 January 2021 00:00 UTC](https://discourse.nodered.org/t/specific-curl-command-in-http-request-node/35776/5 "2021-01-12T00:00:51Z")

</div>

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