Http-connect for POST method is not working

I have created a task to invoke rest call with POST method. Here is the Camunda Connect part of my bpmn file. The same URL is giving a response {“count”: 2} with REST client browser plugin with the same payload. However camunda connect is giving a blank response.

        <camunda:inputParameter name="url">http://localhost:8080/engine-rest/process-instance/count</camunda:inputParameter>
        <camunda:inputParameter name="method">POST</camunda:inputParameter>
        <camunda:inputParameter name="headers">
            <camunda:entry key="Accept">application/json</camunda:entry>
        <camunda:inputParameter name="payload"><![CDATA[{"variables":
[{"name": "myVariable",
 "operator": "eq",
 "value": "camunda"
{"name": "mySecondVariable",
 "operator": "neq",
 "value": 124}],

<camunda:outputParameter name=“serviceOrders”>
<camunda:script scriptFormat=“javascript” resource=“parseResult.js” />

Here is the content for parseResult.js

var response = connector.getVariable(“response”);
//printing the response
print(“Response is :”+response);

@prasadps take a look at:

Thanks Stephen this example indeed helped me :slight_smile: . I also had an issue with the content type which was fixed by setting the content type in the header.

I have one more issue to be resolved. I am mapping the response to a variable WsRespose so that I can access this variable in subsequent service task (java ) and iterate over the SpinList. However script is throwing the below exception.

Caused by: org.camunda.bpm.engine.ProcessEngineException: Cannot serialize object in variable ‘WsResponse’: org.camunda.spin.impl.json.jack

Here is how I set my outputParameter.

         <camunda:outputParameter name="WsResponse">
          <camunda:script scriptFormat="JavaScript">S(response).elements();</camunda:script>

Here is my response

{“customerName”:“Prasad”,"Addr ": “Steet1”,“Pincode” : “12345”},
{“customerName”:“John”,"Addr ": “Steet2”,“Pincode” : “22345”},
{“customerName”:“Linda”,"Addr ": “Steet3”,“Pincode” : “12345”},

@prasadps i think you have to have a Object which contains a array of objects:

  "test-array" : [

So you can modify your javascript to something like:


(probably better to not do it as a single line, but just faster to write it to answer your question)


EDIT: the above probably wont work… the response wont be parsable… please test and if it does not work as just response or S(response) then will test for you.