REST calls examples/manual - way to find all REST calls

Hi All,

Is there a more elaborate manual for all the REST calls? Examples for all the possible BPMN elements? It took me really long to find out how to activate a Conditional-Boundary-Event. It’s not mentioned in the Camunda docs. I looked under Camunda Platform REST API but this is only for conditional-start-events. Eventually found that updating a variable did it but this was not very intuitive.

Another REST call I am looking for is activate the Cancel-Boundary-Event I have set on an transaction-sub-process.

What is the way to find out?

Cheers, Steven

There are some tutorial videos that might be useful to follow

1 Like

Thank you for the reply. I have seen those but they give the basics. For some BPMN elements it is very straight-forward but for others it is not transparent what to do.

We don’t really have a list of symbols with a corresponding way to trigger it.
But a lot of symbols don’t actually have a REST Trigger (like compensation, timers and escalations)

For a timer I can imagine it is triggered automatically but how will the compensation or escalation be activated when wanting to use the REST interface?

I found the following that does ends the specific activityInstanceId (of the transactional-sub_process):
http://localhost:8080/engine-rest/process-instance/a200c737-70a7-11e9-a3ed-0242ac110002/modification-async
{
“instructions” : [{
“type”: “cancel”,
“activityInstanceId”: “Task_1pn2lqb:a200c73c-70a7-11e9-a3ed-0242ac110002”
}]
}

Only thing is that it doesn’t start the follow-up event/task. Is this the proper way to cancel a transactional-sub-process and trigger it’s cancel-boundary-event?

I found the following webpage that uses JavaScript and Groovy to throw a BpmnError. So, I thought to try this concept out as a Task listener but I get a groovy error: Script3.groovy: 1: Invalid variable name. Must start with a letter but was: cannotResolvecannotRes
What is the problem here?

These are my settings for the complete task-listener:
Event Type: complete
Listener Type: Script
Script Format: groovy
Script Type: Inline Script
Script:
def cannotResolve = execution.getVariable(“cannotResolve”);
if ( cannotResolve == true ) {
throw new org.camunda.bpm.engine.delegate.BpmnError(“CannotResolveError”)
}

And when I complete the task I thus set the variable “cannotResolve” to “true”…

Hi @stevena,

With the script above, you check the value of the process variable “cannotResolve”. You don’t set it, you only check whether it’s true.
I assume you have set it somewhere else and here you only need to check it.
Is this what you want to achieve?

Yes, In the meantime I changed it to:
if (cannotResolve) {
throw new org.camunda.bpm.engine.delegate.BpmnError(“CannotResolveError”)
}

But now I get another exception:
An error happened while submitting the task form : Cannot submit task form 3e5d88b7-716a-11e9-a3ed-0242ac110002: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘null’

So what I made is a User Task that has a Error Boundary Event. I want to activate the Error Boundary Event via REST or programmed within the BPMN diagram when the task completes (or with any other way possible when this task is active).
Maybe its not possible via a listener since its activated when the task completes and the Error Boundary Event is already gone…?

See this thread

Oke, I see. The engine doesn’t complain when I put a Error Boundary Event on a User Task though. Anyway, I tried also to use a Message Boundary Event on a User Task but somehow when calling it with http://localhost:8080/engine-rest/message it isn’t recognized. I added a processInstanceId but that also didn’t help.
This was the JSON code I passed along:
{
“messageName” : “cannot_find_fault”,
“businessKey” : “1”,
“processInstanceId” : “5b264191-70c6-11e9-a3ed-0242ac110002”
}

I guess you process instance has indeed a businessKey = 1, so the REST call can do the correlation.
In that case, I don’t know what is wrong.

Edit: By the way, is the User Task active when you send the REST call? (so the message event is in “waiting” state)

cannot_find_fault.bpmn (8.2 KB)

The moment I have set the Expression in the Message Intermediate Throw Event “${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“start_second_process”).correlateWithResult()}” the REST call stops working and I get the error:
{
“type”: “RestException”,
“message”: “org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘cannot_find_fault’: No process definition or execution matches the parameters”
}

For my understanding and trying to isolate where the problem comes form, does the triggering of the message boundary event work if you don’t have the message throw event right after it?
How do you send the REST call to trigger the message boundary event? with some code or any app like Postman?
Could you try using the “asynch before/after” and see where the transactions stop when the error occurs?

For triggering the execution of the second process from the message throw event, I think you need to call the “startProcessInstanceByMessage” and not the “createMessageCorrelation”.

Found it. The process I send was an example I quickly made and it started to work out of itself when I did a re-deploy. The problem was the call to the sub-process. In my process I use the Message Boundary Event is in process called and needed a businessKey. Completely overlooked it!

Now it executes when I do (pffff):
${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“start_second_process”) .processInstanceBusinessKey(“2”).correlateStartMessage()}

I tried it also with startProcessInstanceByMessage but I don’t know how to pass an empty Map: <this doesn’t work>${execution.getProcessEngineServices().getRuntimeService().startProcessInstanceByMessage(“start_data_collector_check_steps”, “2”, [:])}</this doesn’t work>

What is a common way to have a dynamic businessKey defined?

Anyway, thanks for the help! Cheers!