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

**URL:** <https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243>\
**Category:** Flowable Application\
**Created:** [July 19, 2018, 10:02am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243 "2018-07-19T10:02:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 19, 2018, 10:02am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/1 "2018-07-19T10:02:11Z")

</div>

Hey everyone,

In request body I can only type out my JSON body, but can’t use variables (ones I got using script task), i.e. **${myVar}** , since those are strings with quotation and unsuitable for REST calls.

Any advice on using REST API?

---

<div class="post-metadata">

**Author:** ![jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jan](https://forum.flowable.org/u/jan)\
**Post date:** [July 20, 2018, 5:22am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/2 "2018-07-20T05:22:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 20, 2018, 7:15am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/3 "2018-07-20T07:15:18Z")

</div>

Thanks.  
It seems I can’t set the type from inside the modeler. Any quick workaround?

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [July 20, 2018, 9:37pm UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/4 "2018-07-20T21:37:26Z")

</div>

You don’t need to, when selecting the Http task, the type will be set automatically for you.

---

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 21, 2018, 6:34am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/5 "2018-07-21T06:34:55Z")

</div>

That’s true, but I need to set the type of a service task if I want to use those fields.

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [July 21, 2018, 10:49am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/6 "2018-07-21T10:49:54Z")

</div>

Which modeler are you using? With the flowable-modeler application has a specific HTTP Task that you can drag and drop and you would be able to add all the information that @jan linked in the modeler

---

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 21, 2018, 11:48am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/7 "2018-07-21T11:48:19Z")

</div>

Hey,

> [@jan](#):
>
> \<flowable:field name=“requestBody”\> \<flowable:expression\>\<![CDATA[${jsonVariable}]]\>\</flowable:expression\>

I need the request body to be an expression, not a string. I think it’s string since my test cases failed and I think it’s due to quotation.

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [July 21, 2018, 12:59pm UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/8 "2018-07-21T12:59:26Z")

</div>

Exactly and if you go in the editor and in request body you write: `${bodyExpression}` then you will have

```auto
<flowable:field name="requestBody">
    <flowable:expression><![CDATA[${bodyExpression}]]></flowable:expression>
</flowable:field>

```

in your BPMN xml. Can you perhaps share a reproducal with your problem. Perhaps the test case and the BPMN XML. As this should work

---

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 21, 2018, 2:41pm UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/9 "2018-07-21T14:41:07Z")

</div>

You are correct. I will reply again If I don’t get it working. Thanks

---

<div class="post-metadata">

**Author:** ![Savo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/savo/32/722_2.png) [@Savo](https://forum.flowable.org/u/Savo)\
**Post date:** [July 23, 2018, 9:08am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/10 "2018-07-23T09:08:42Z")

</div>

It works now. First time I downloaded BPMN XML I got the !CDATA[GET] instead of !CDATA[PUT]. But the next day it was PUT, and it everything just worked. I haven’t changed anything in comparison to what I had when I posted the problem.

Thanks for helping out.

---

<div class="post-metadata">

**Author:** ![poly](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@poly](https://forum.flowable.org/u/poly)\
**Post date:** [July 7, 2022, 2:51pm UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/11 "2022-07-07T14:51:42Z")

</div>

unfortunately it gives always flowable:string in request body when the change is made in the modeler,  
even when I manually changed the xml to flowable:expression and re’uploaded it, it goes back to string. I just want to send the ${caseInstance.id} in the body and everytime it’s sent as a string not the value behind. can you help ?

---

<div class="post-metadata">

**Author:** ![poly](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@poly](https://forum.flowable.org/u/poly)\
**Post date:** [July 12, 2022, 10:37am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/12 "2022-07-12T10:37:09Z")

</div>

in cmmn models it’s always string in request body 🙄 I didn’t find a way to make it an expression, in bpmn it’s fine though but we don’t use bpmn models.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [July 20, 2022, 9:00am UTC](https://forum.flowable.org/t/how-exactly-should-i-use-put-post-in-http-task-when-i-am-limited-to-only-strings-for-request-body/2243/13 "2022-07-20T09:00:53Z")

</div>

I’ve answered this on 2 other posts. Please refrain from creating 4 posts about the same problem.
