How to specify POST payload for Rest Tasks?

Hello everyone.

I have to complete a process with Connector service tasks to hit an external REST API directly from BPMN. If I understood well, I don’t necessary need JS and can program an automated Rest call right in the BPMN structure, as show in the example below:

However this is GET call, and I must need an extra markup for the payload body. I have found this topic about POST call from workflow, but I wasn’t that clear to me.

Once this done I’ll try running through my process. Here is a copy of my BPMN file. The first parallel tasks to be reached are my Rest call, for the moment they have no payload.

Thanks for your time
launchCancel.bpmn (26.8 KB)

You just need to specify one more input parameter as shown in the above diagram

Thanks for your answer. In fact, I’m seeking to build a Rest payload for a POST request in my BPMN task.

I had a look at this topic :

and it looks that @StephenOTT found how to concatenate a JSON payload for his POST call after getting his process variables.
But when I start my process (by REST) with a submit start form with my process variables, I see that variables that were used in payload script have null values in cockpit while I gave it a dummy value to test it.

In case this works like a response handling JS, I gave the script the name of a my variable “payload” (a string to contain the Json). But I can’t get this working to call my REST api. I also added Content-Type application/json to my headers.
Here is my BPMN : testRest.bpmn (8.0 KB)

Where is the problem from ? :neutral_face:

I have always built my payloads using the Freemarker Template language. For example:

{
	"variables" : { 
		"rawMessage" : {"value" : "${rawMessage?js_string?replace("\\'", "\'")}", "type" : "json" },
		"bpoCaseId" : { "value" : "${bpoCaseId}", "type" : "string" },
		"bpoCreateCaseId" : { "value" : ${bpoCreatedCaseId?c}, "type" : "boolean" },
		"debugMode" : { "value" : ${debugMode?c}, "type" : "boolean" }
	}
}

This is bit more complex, but basically it shows how a JSON encoded payload can be constructed. Each ${} is a process variable value. Each “?” is a modifier or function defined for Freemarker.

I like it because it’s easy to understand and it looks like the message payload itself. You can put this code into the payload definition of the HTTP connector or you can create an external file with and use it as a resource.

Here’s link to the Freemarker manual: http://freemarker.org/docs/

@mppfor_manu Thanks for your answer. I also ended up using freemarker