Add a variable using ProcessInstance Id


I’m trying to add a global variable to an existing process using ProcessInstanceId, but I can’t find the way to do it. RuntimeService uses the executionid for this, which I don’t have. I checked the rest api, and there is Camunda Platform REST API
which seems exactly what I need, but I fail to find the Java API counterpart for it.

I know I can add variables from delegates, when creating the process, etc, but my use case is to add a variable before deleting a processinstance because of an external event (related to other question I asked, Restart Process Instance adding a new variable)



Ok, turns out that RuntimeService first parameter can be executionId or processInstanceId according to

So runtimeService.setVariable(processInstanceId, "variableName", "variableValue"); works just fine.