Calling REST api

#1

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.

0 Likes

#2

what have you tried?

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

0 Likes

#3

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

0 Likes

#4

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

0 Likes

#5

Yes as per the answer in the other thread.

0 Likes