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?
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?
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.
Thanks.
It seems I can’t set the type from inside the modeler. Any quick workaround?
You don’t need to, when selecting the Http task, the type will be set automatically for you.
That’s true, but I need to set the type of a service task if I want to use those fields.
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
Hey,
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.
Exactly and if you go in the editor and in request body you write: ${bodyExpression}
then you will have
<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
You are correct. I will reply again If I don’t get it working. Thanks
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.
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 ?
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.
I’ve answered this on 2 other posts. Please refrain from creating 4 posts about the same problem.