Hello,
I need to set up a Payload, and call a Rest API, this API will return me a JSON, with a response ID. I’m having trouble capturing this response ID to call my next Rest API, because it needs the ID as a parameter. can you help me? How i mount this Payload? and how i get data response?
This is the payload I need to set up:
HTTP POST
{
“email”: “string”,
“name”: “string”
}
Response
{
“id”: “string”,
“email”: “string”,
“name”: “string”
}
After that, I need to get the ID and call my next task. can you help me?
This is my BPMN
Thanks =)
We are doing something similar with groovy scripts. We use jsonSlurper to parse the json body and retrieve an ID. We use Jsoup to perform rest calls rather than HTTP-Connector; I have read there are timeout issues with HTTP-Connector. Here’s a snippet that pulls an ID out of a response body and sends a rest call with JSoup:
def jsonSlurper = new JsonSlurper()
def eventTypeId = jsonSlurper.parseText(doc.body()).data.ID
url = baseUrl + version + '/orders/' + detailsId + '/events';
def str = "{\"EventType_ID\" : \"" + eventTypeId + "\"," +
"\"DateCreated\" : \"" + easternTime + "\"," +
"\"EventData\" : \"" + msg + "\"," +
"\"username\" : \"" + createdBy + "\"," +
"\"CreatedBy\" : \"" + createdBy + "\"}";
doc = Jsoup.connect(url)
.method(org.jsoup.Connection.Method.POST)
.header('Accept', 'application/json')
.header('Content-Type', 'application/json')
.requestBody(str)
.timeout(30000)
.ignoreContentType(true)
.execute();