How can I send an HTTP request to a workflow and read the HTTP body with Node.js?

This topic was automatically generated from Slack. You can find the original thread here.

Oleg Borodko : hello. Can you help me - I don’t understand how I can send body parameters and then read them with nodejs

Dylan Sather (Pipedream) : HI , the easiest way to do this is using a Pipedream workflow.

First, select the HTTP / webhook trigger. This will generate a unique HTTP endpoint you can send data to.

If you send an HTTP POST request to that endpoint, you data will be made available in the variable steps.trigger.event.body . For example, if I send a name in the body, it’ll show up in steps.trigger.event.body.name:

curl -d '{ "name": "Dylan" }' https://myendpoint.m.pipedream.net

Dylan Sather (Pipedream) :

Screen Shot 2020-11-23 at 1.30.32 PM.png

Dylan Sather (Pipedream) : you’ll see the event arrive to the left of your workflow. If you select it, you can inspect the event data in the trigger step, like I did here

Dylan Sather (Pipedream) : then you can add a new Node.js code step below that:

Dylan Sather (Pipedream) : In my example above, I’d log the name like so:

console.log(steps.trigger.event.body.name)

Dylan Sather (Pipedream) : feel free to copy this example workflow

Dylan Sather (Pipedream) : just wanted to check in to see if this worked for you