MESSAGE START EVENT- Accessing payload from POSTMAN and passing onto REST Endpoint

restEndointTask.bpmn (4.8 KB)

FLOW
POSTMAN -> Message start event -> restendpoint1 -> restendpoint2 -> END

(1)From postman I’m sending data as below to MESSAGE START EVENT
{
“messageName” : “startMessageRestProcess”,
“businessKey” : “1”,
“processVariables” : {
“messagaData” : {“value” : {
“name”:“james”,
“surname”:“wood”
}, “type”: “String”
}
}
}

(2) Later i need to pass “NAME” and “SURNAME” to RESTENDPOINT1

(3) RESTENDPOINT1 returns me data in below format
{
“age”:“30”,
“address”:999 King Street,London"
}

(3)I need to pass “AGE” and “ADDRESS” ,which i received from RESTENDPOINT1’s response to the RESTENDPOINT2

Kindly Suggest me where I’m getting wrong or Kindly update the .BPMN file
TIA

@james1980 whats the issue you’re facing? Provide the error stacktrace.

@aravindhrs Above is the stack trace.Kindly let me know,where i’m getting wrong or you can edit my .BPMN file as well
TIA

@Niall @aravindhrs and camunda team, anyone can help me go through this…its been a while im stuck up and not able to proceed further…

@james1980, your payload is incorrect. Refer this page correlate-message for starting process instance using message start event.

Payload should be like this for correlation request:

{
    "messageName": "startMessageRestProcess",
    "businessKey": "1",
    "processVariables": {
        "name": {
            "value": "James",
            "type": "String"
        },
        "surname": {
            "value": "Wood",
            "type": "String"
        }
    }
}
2 Likes

@aravindhrs Thanks for above answer it working,but how do i access
RESTENDPOINT1 response which as below and pass to RESTENDPOINT2 input payload?

RESTENDPOINT1 response ===>
{
“age”:“30”,
“address”:999 King Street,London"
}

====================================
RESTENDPOINT2 input payload
{
“rest2Age”: (HOW DO I ACCESS HERE ??? )
“rest2Address”: (HOW DO I ACCESS HERE ??? )
}

@james1980, try like this, i haven’t tested yet.

image

And make sure both the service tasks are executed in synchronous fashion. If you marked as async, then you need to save the response as process variables.

@aravindhrs Below seems to work !

var json = S(response);
var ageProperty = json.prop(“age”);
var age= ageProperty .value();
age;

How to send REST_END_POINT2 response as below back to the POSTMAN?
{
“grade”:“A”,
“eligible”:“YES”
}

@james1980 all the service task are executed in same thread? Synchronous execution?

If it’s synchronous execution, you can save the response as process variables.

In the start instance request, you can set variablesWithReturn =true

1 Like

@aravindhrs its working thanks