Creating json object to pass to camunda start instance rest api (application to be migrated to C8 later)

Hi there,

I am trying to call camunda start process instance rest api from my java class -
{{rest_url}}/process-definition/key/{key}/start

now this endpoint needs object in the structure as below -

{
“variables”: {
“age” : {
“value” : 25,
“type”: “Integer”
},
“carManufacturer” : {
“value” : “VW”,
“type”: “String”
},
“carType” : {
“value” : “BMW”,
“type”: “String”
}
},
“businessKey” : “myBusinessKey2”
}

now I have a map of values that I want to covert in the input structure as required by rest api call, here’s my map -

{
“businessKey” : “123”,
“caseStatus”: “Dummy”
}

Please advise how how this can be done or if there’s a better way to create the payload for camunda rest api call ( start process instance and others).

Please note: we want to migrate this application to camunda 8 at a later point in time, so want to keep boilerplate code to minimal possible.

Thanks

any suggestions please.

Hi @Pramod_Yadav,

Which language are you using?
In general, I recommend that you add an extra abstraction layer, that encapsulates the calls to the Camunda API and offers stable interfaces. When you switch to Camunda 8, you only need to adapt this abstraction layer.
The OpenAPI specification and or the external task client can be a good starting point. They especially cover things like starting a process instance.

Hi Stephan,

we are using java.

Thanks

Consider the following client in the community hub, it takes care of serializing Variables:

The following example shows, how a process can be started: