Return Values from HTTPTask Rest Call


I am new to Flowable, but i have successfully called an external RESTful API thru HTTP Task, but i want the response from HTTP Task returned back to me so i could return it back to the caller, is this possible?

Sample code:
public CommonResponse startProcess(Interview interview) {


    CommonResponse commonResponse = new CommonResponse(
        CommonResponse.SUCCESS, CommonResponse.SUCCESS);

    try {
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("sampleRequestBody", interview);

        runtimeService.startProcessInstanceByKey("timerProcess", variables);
    } catch (FlowableObjectNotFoundException  e) {
        return commonResponse;

    return null;

So instead of returning null at the bottom, i would like to return the response from the call.


Has the process instance finished immediately after the start process instance was started? Or is it still running and waiting in a user task for example?
If the process instance is still running you can use the runtimeService getVariables method to get the process variables. If the process instance has ended you could use the HistoryService to get the process variables.

Best regards,


Thanks for the reply.

The process instance has ended, and i have added History Service code already but got no process variables.
See code below:
runtimeService.startProcessInstanceByKey(“timerProcess”, variables);

        List<HistoricProcessInstance> history =

        for (HistoricProcessInstance historyInstance: history) {
            Map<String, Object> response = historyInstance.getProcessVariables();
            for (Entry<String, Object> entry : response.entrySet()){
                System.out.println(entry.getKey() + " " + entry.getValue());

Please help why there is no process variables? Is it because “returnVariables” is not set to true?
If yes, how to set “returnVariables” to true thru Java?

I think i have gotten the response using this code snippet:
List history =
.orderBy(new TaskQueryProperty()).desc()
.listPage(0, 1);


if in this query you also add


you can then access process variables also for a particular process instance otherwise you have to write history variable query also which you posted in your last comment.


1 Like