11-15-2018 01:19 PM
Hi - Does anyone have an example how to create a custom API which receives a JSON body in a POST.
Also, how to do you specify a POST vs GET in the task?
I found a couple examples but most use parameters which I want to avoid.
Any help is appreciated.
Thanks,
Jose
11-15-2018 03:32 PM
REST Get and REST Post are 2 distinctive snap.
As for providing JSON body in a REST POST. It is quite straight forward with this POST to Slack as an example:
Plug in your Slack channel REST URL. “HTTP entity” is essentially your BODY and $ represent the JSON document you are getting from the input. If you have multiple docs feeding into your input, it will execute as many REST POST per doc. If you like to only execute once then you could use Group by snap to push an array into 1 document.
Note: you also have an option to place the actual JSON body in the “HTTP entity” field as well.
For Slack it only needs “text” in the body of REST POST, so I can feed the message I want to it.