cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti REST API and

mwm1
Champ in-the-making
Champ in-the-making
Dear all,
I have one program client which use Activiti REST API to start process using CXF such as below:


ProcessInstanceCreateRequest reqProcess = new ProcessInstanceCreateRequest();

      reqProcess.setProcessDefinitionKey("processRequest");
      variable.setName("requestFromClient");
      variable.setValue(requestObject);
      reqProcess.setVariables(variables);
      
      int resp = WebClient.fromClient(rsWebClient)
            .header("Authorization", setUser()).accept("application/json")
            .type("application/json").path("/service").path("/runtime")
            .path("/process-instances").post(reqProcess).getStatus();

      return resp;


That works well.

On the other hand, I have deployed process running on Tomcat  with Activiti REST which consume Request from the client to finalize process flow.

The problem I can't do execution.getVariable("requestFromClient")

If I make toString, I can see the request from client
LOGGER.info("requestFromClient–>"
            + execution.getVariable("requestFromClient").toString());

I can see either all variables in the process by doing

for (String string : varNames) {

         LOGGER.info("Variable Named " + string + " exists");
      }


My question is how to get request from client in the process. Actually, I have  execution.getVariable("requestFromClient")  which is null.
Thank you for your reply.
Best regards
😉
2 REPLIES 2

trademak
Star Contributor
Star Contributor
I don't understand what you are doing exactly. Can you include the full source code of the part where you want to execute the execution.getVariable method?

Best regards,

mwm1
Champ in-the-making
Champ in-the-making
Now I solved that issue by using ObjectMapper as below
<java>
  ObjectMapper mapper = new ObjectMapper();
    JSONObject objectJson = new
    JSONObject(execution.getVariable("requestFromClient").toString());
    String obj=String.valueOf(objectJson);
    LOGGER.info("object  –>" +objectJson );
     Request reqFromClient = mapper.readValue(obj, Request.class);
</java>