# Calling REST api

**URL:** <https://discourse.nodered.org/t/calling-rest-api/1089>\
**Category:** General\
**Created:** [26 June 2018 05:56 UTC](https://discourse.nodered.org/t/calling-rest-api/1089 "2018-06-26T05:56:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sampath6789](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@sampath6789](https://discourse.nodered.org/u/sampath6789)\
**Post date:** [26 June 2018 05:56 UTC](https://discourse.nodered.org/t/calling-rest-api/1089/1 "2018-06-26T05:56:29Z")

</div>

Hi.

I want to know how to call a given rest api with a request body and get the response from node-red

eg:  
header:  
Content-Type: application/json  
body:  
{  
“key1”:“value1”,  
“key2”:“value2”  
}

Thank you.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 June 2018 06:23 UTC](https://discourse.nodered.org/t/calling-rest-api/1089/2 "2018-06-26T06:23:30Z")

</div>

what have you tried?

Have you read the info panel on the http-request node?

---

<div class="post-metadata">

**Author:** ![sampath6789](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@sampath6789](https://discourse.nodered.org/u/sampath6789)\
**Post date:** [26 June 2018 06:25 UTC](https://discourse.nodered.org/t/calling-rest-api/1089/3 "2018-06-26T06:25:32Z")

</div>

I found the answer.  
we need to use 4 nodes.

1. inject
2. change
3. http request
4. debug

set headers as rules(msg.headers) in change node.  
set body as rules(msg.payload) in change node  
set endpoint in http request node

after connecting those nodes click on the inject node. then the request will be gone and response will be received

---

<div class="post-metadata">

**Author:** ![sampath6789](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@sampath6789](https://discourse.nodered.org/u/sampath6789)\
**Post date:** [26 June 2018 06:30 UTC](https://discourse.nodered.org/t/calling-rest-api/1089/4 "2018-06-26T06:30:02Z")

</div>

Thanks for replying…

Do you know which node to be used to access the elements in the http response received.  
I want to get the elements in the json object.  
Thanks

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 June 2018 06:30 UTC](https://discourse.nodered.org/t/calling-rest-api/1089/5 "2018-06-26T06:30:51Z")

</div>

Yes as per the answer in the other thread.
