Set access token in request header

Hi

I am trying to use http task. I want to send an Http request with an access token:

<serviceTask id="httpGet" name="HTTP Get" flowable:type="http">
  <extensionElements>
    <flowable:field name="requestMethod">
      <flowable:string><![CDATA[GET]]></flowable:string>
    </flowable:field>
    <flowable:field name="requestUrl">
      <flowable:string><![CDATA[http://localhost/api/v2/users]]></flowable:string>
    </flowable:field>
    <flowable:field name="requestHeaders">
      <flowable:expression><![CDATA[${headers}]]></flowable:expression>
    </flowable:field>
  </extensionElements>
</serviceTask>

I want to set an access token in headers:

   Map<String, Object> variables = new HashMap<>();
    variables.put("headers", "Authorization:  Bearer 0d65dbfa-73y6-41y7-8eaa-29c4e3973f46");
    String procId = runtimeService.startProcessInstanceByKey("simpleGetOnly").getId();
    List<HistoricVariableInstance> variables2 = 
   historyService.createHistoricVariableInstanceQuery().processInstanceId(procId).list();

but it does not work.

org.flowable.common.engine.api.FlowableException: Unknown property used in expression: ${headers}

what is wrong in my code? how should I send access token in my http request?

You’re not passing the variables map to the startProcessInstanceByKey method.

thank you.

it works :slight_smile:

Is there any feature in flowable for oauth2? for calling http services in a http task?