ERROR: execution <process instance id> doesn't exist: execution is null

Hi, I am trying to set and unset an execution variable using process instance Id.
I save the process instance Id in database initially, and from a REST API , get the same instance Id to set and unset the variable.

My understanding is, that for a particular execution, the process instance Id remains same through out.
I set the variable as follows:

public static void setPauseVariable(String processInstanceId, boolean pause) throws Exception {
		
		try {
			HttpClient httpclient = HttpClientBuilder.create().build();
			String uri = "http://localhost:8080/engine-rest/process-instance/" + processInstanceId + "/variables/pause";
			HttpPut httpPut = new HttpPut(uri);
			JSONObject requestJson = new JSONObject();
			
			requestJson.put("value", pause);
			requestJson.put("type", "boolean");
			StringEntity entity = new StringEntity(requestJson.toJSONString());
			httpPut.setEntity(entity);
			httpPut.addHeader("content-type", "application/json");
			HttpResponse response = httpclient.execute(httpPut);
			if (response != null) {
	            if (response.getStatusLine().getStatusCode() != 204) {
	            	throw new Exception(EntityUtils.toString(response.getEntity(), "UTF-8"));
	            }
			}
		}catch(Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

Why do i get this error:
execution doesn’t exist: execution is null

Hi Urvashi,

what is the content of processInstanceId?
Can you verify that this process instance really exist?

Greets
Chris

Hi

I ran this to test,
/engine-rest/process-instance/e47b66f1-51d0-11e8-aa4a-0242ac11000e

and it says that “Process instance with id e47b66f1-51d0-11e8-aa4a-0242ac11000e does not exist”. Now it makes sense why execution is coming as null.

But the thing is, my instance is still running. I can see it printing continuously on my console . (I had kept a loop that prints every 5 seconds indefinitely). Then what is the reason that the instance Id is not showing up. :frowning_face:

Am I missing something really basic here?

Hi,

please check with a GET request to /engine-rest/process-instance (see https://docs.camunda.org/manual/7.8/reference/rest/process-instance/get-query/)

Whether the process instance with this ID truly exist or not. Furthermore with the response you
are able to find out the correct ID.

Greets
Chris

I did check this,…/engine-rest/process-instance
My process instance is not in the list. even though its running.

Please read my updated answer on your other post Process instance Id null