How to start a process via REST-API with a "plain" JSON payload?

2,184 views
Skip to first unread message

Matthias Reining

unread,
Dec 17, 2014, 8:09:59 PM12/17/14
to camunda-...@googlegroups.com
Hi all,

I was wondering how to start a process via REST-API with a "plain" JSON payload?


My question belongs more to the "plain" JSON payload. My payload is a JSON data structure that is not structured in the "Camunda way" as {"aVariable" : {"value" : "aStringValue", "type": "String"}. There is no type information in my JSON data strucutre available -> "plain JSON".

Is there a possiblity to pass an individual JSON object? I already tried to package everything into a quoted string and pass as one variable. Unfortunately, in this case I cannot use the object in the BPMN conditions.

Different BPM processes should be started from different clients / systems (SOA landscape). At the moment, all clients have to remap the existing JSON data structure in the Camunda JSON data structure. Furthermore, I would also like to pass complete data structures (deep data structures) and not only flat data structures.

How do you normally solve this scenario?

Thanks, Matthias

Roman Smirnov

unread,
Dec 18, 2014, 4:49:28 AM12/18/14
to camunda-...@googlegroups.com
Hi Matthias,

Just for me to understand your request correctly:

You have a "plain" JSON object like this:


  { "x" : "abc", "y" : 123, ... }
 

And at the moment you have to transform the "plain" JSON into the "Camunda way" JSON like this:


  { "x" : { "value" : "abc" }, "y" : { "value" : 123 }, ... }
 

... so that you are able to start a process instance with variables via REST API.

Is that correct? Or what what do you mean with a "plain" JSON?

Cheers,
Roman

Matthias Reining

unread,
Dec 18, 2014, 5:29:14 AM12/18/14
to camunda-...@googlegroups.com
Hi Roman,
exactly!

I'd like to avoid this transformation in the client that start the process.

Thanks, Matthias

Daniel Meyer

unread,
Dec 19, 2014, 3:51:00 AM12/19/14
to camunda-...@googlegroups.com
Hi Matthias,

I would propose to post the json as follows:

{ "jsonInput" : { "value": "{ \"x\" : \"abc\", \"y\" : 123, ... }", "type": "String" } }

You can then use camunda Spin for evaluating conditions:

<sequenceFlow>
 
<conditionExpression xsi:type="tFormalExpression">
    ${ S(jsonInput).prop("y").numberValue() > 10 }
 
</conditionExpression>
</sequenceFlow>

(Json Path is also supported).

Further reading:

Does that help you?

Regards,
Daniel

Message has been deleted

Matthias Reining

unread,
Dec 19, 2014, 10:19:20 AM12/19/14
to camunda-...@googlegroups.com
Hi Daniel,
thanks! 

camunda Spin was new for me. This solution will help me for sure.

But also in this case, the client (process starter) has to quote the payload and for designing BPMN condition the BPMN designer have to know that there is a special format (in summary, not really nice...)

But, in any case, the solution you pointed out looks good and solve my problem in a more or less nice way.

Cheers, Matthias
Reply all
Reply to author
Forward
0 new messages