Http-connector POST Call with optional query parameter


I am using http-connector to call my rest service.
Do we have any way to set optional query parameter in this?
Can I have some example of that.

Like POST call url: http://localhost:8090/getCustomerDetails?customerId=#{customerId}&Id=#{Id}
Here we can have either customerId or an Id or both in the Query parameter.
But as we can see in the image, I can only configure static url in url input parameter…


Use a script for your URL input. And have the script build your URL with the query params as you see fit with your logic


Any Example for that…
The variable will be available before the task execution… So how will I access that… And How will I set that…


You change your URL input variable from Type: Text, to Type: Script. Then write a script that returns a String / last executed line returns a string. You could use Javascript or Groovy easily for this.



see for examples of scriptS:


Trying this…
<camunda:inputParameter name=“url”>
<camunda:script scriptFormat=“javascript”>var a = 'http://localhost:8090/getCustomerDetails?’;
if(${customerId}== null)
return a;</camunda:script>

It’s giving me an error for javascript input parameter

15-Apr-2019 17:33:50.126 WARNING [http-nio-8080-exec-10] org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script while executing activity ‘ServiceTask_198fofb’ in the process definition with id ‘Akku:1:6d9df9b6-5f76-11e9-873f-00155d2c2673’::2:4 Expected ) but found {
if(${customerId}== null)
^ in at line number 2 at column number 4

This parameter has been introduced in the starting of process Instance as an string variable.


That is not JavaScript. You are mixing JavaScript with other things like java expression Lang ${}.

See the scripting docs for Camunda that I linked to above. Read those in detail as they explain exactly how to access variables.


Thanks a lot Stephen.
It’s working for me.
Thank you very much.

<camunda:script scriptFormat=“javascript”>
var a = 'http://localhost:8090/getCustomerDetails?’;
if(customerId== null)