How exactly should I use PUT/POST in Http task when I am limited to only strings for Request body

I’m using HTTP tasks for API calls with variables from script tasks without problems. Example:

<serviceTask id="http_example_task" name="HTTP example task" flowable:type="http">
  <extensionElements>
    <flowable:field name="requestMethod">
      <flowable:string><![CDATA[PUT]]></flowable:string>
    </flowable:field>
    <flowable:field name="requestUrl">
      <flowable:expression><![CDATA[${propertyService.getValue('my.domain.url')}/app/api/v1/endpoint]]></flowable:expression>
    </flowable:field>
    <flowable:field name="requestHeaders">
      <flowable:string><![CDATA[Content-type: application/json]]></flowable:string>
    </flowable:field>
    <flowable:field name="requestBody">
      <flowable:expression><![CDATA[${jsonVariable}]]></flowable:expression>
    </flowable:field>
    <flowable:field name="failStatusCodes">
      <flowable:string><![CDATA[400,401,403,404,415,500]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>

Please mind the flowable:expression when you need to evaluate variable.

1 Like