REST call using http-connector and external JSON payload

Hi Everyone!

I have a REST endpoint that I would like to POST to using Camunda. The payload is JSON format and I would want to test it using postman or insomnia.

In the modeler, what would be my payload? If I leave it blank, then the service is not receiving anything. Here is a screengrab of the model.

Thanks!!

1 Like

Your JSON goes in the VALUE box.

image

I am aware that we can put the JSON payload in the Value field box. My question was - how do we use postman or insomnia or for that matter any http client to call the process engine endpoint and pass the JSON payload?

What would i put in the value field in this case?

Trying to understand your question, I use SOAPui and you can register an endpoint with your method and payload, I have used other REST clients (ARC) and there is always a place to define that.

I am using Insomnia and have pasted the JSON payload there and sending it to the Camunda process start endpoint. In the modeller, I have kept the Input parameter ‘Payload’ (text) value blank.

When i am posting from insomnia, i am getting this error -
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing

When I am posting the same JSON body in the value field of the Camunda modeller, it works fine.

What am I doing wrong?

Can anyone answer this question because I am trying to do the same thing. I want to post a json payload to a camunda BPMN process and extract that json in a java class that is attached to the service node in the BPMN process.

I had not used Insomnia, downloaded it and made a very simple example of accessing an endpoint and it works well. Actually I do not know what you’re doing wrong.
With more time I do a test to access the REST API of Camunda and create process instances.

I use this endpoint in the modeler for a demonstration and it works well.

The endoint I am POSTing to is the Camunda process engine start endpoint - http://localhost:8080/engine-rest/process-definition/key/xxxx/start. When I POST to this endpoint from Insomnia or postman using a JSON payload, The microservice complains that it did not receive a payload(please refer to the error I have pasted in my previous comment). Question is, how do I get Camunda modeller to accept an external JSON payload? Do I have to configure the start event in the modeller in some special way? What do I put as the value field of the payload of the service event in the modeller?

Here is my Insomnia -

And here is my modeller -

Here I am using insomnia to start instances of processes. The payload is very specific of what you have to send to the endpoint.

My Spring Boot REST Controller accepts a CustomDTO as the RequestBody.
My Payload from Insomnia or postman is as follows just like you pasted above -

{
“variables”:
{
“CustomDTO”:
{
“value”:“Stringified CustomDTO JSON”,
“type”:“json”
}
},
“businessKey”:“xxx”
}

But I am still getting the same exception from the Spring Boot app saying -

.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.xxx.dto.CustomDTO com.xxx.controller.xxxController.createEvent(com.xxx.dto.CustomDTO) throws com.fasterxml.jackson.core.JsonParseException,com.fasterxml.jackson.databind.JsonMappingException,java.io.IOException]

Any inputs anyone please?

When you put a joson as a payload inside the variable element, the quotes must be backslashed. below is an example

{
“variables”:{
“person” : {
“value” : “\n {\n “address”: {\n “address1”: “3388 Einstein Square”,\n “address2”: “Heinz Weigenzhul Lane”,\n “city”: “Pforzheim”,\n “postalcode”: 55555,\n “state”: “Germany”,\n “country”:“Comal Germany”,\n “id”:2\n },\n “age”: 6,\n “email”: "marco@Bunte.com”,\n “first_name”: “Marco”,\n “last_name”: “Bunte”,\n “phone”: “333-222-8888”,\n “person_id”: 199\n }\n",
“type”: “json”

}

},
“businessKey” : “myBusinessKey”,
“withVariablesInReturn”: true
}