Passing payloads carried by inbound Webhook connector to payload of an outbound HTTP connector

I am trying to build a workflow, locally, on my Ubuntu 22.04, using JDK 21. The desktop modeller version is 5.30.0.

I have a simple workflow. It starts when a Webhook calls into it. The variables that the Webhook carries are “bucket” : “” and “document”: .

Once the Webhook is received, these two values are stored in process variables of the same name: bucket and document.

The Workflow simply passes these two, to an outbound HTTP connector. This is a Spring Boot based Java application running, at a known port. The process variables (two, mentioned above) are to be associated with the payload (POST) of this outbound HTTP connector. So, this is what I do (in the modeller):

I have assumed that the exchange is going to be this much only. But, that is not the case. The call to the outbound HTTP connector fails. The ‘operate’ web console tells me that HTTP connector has responded with a HTTP:400 (Bad request).

It is obvious from the picture that the Webhook has done its job correctly and the process variables indeed are initialized alright. But, the outbound HTTP connector isn’t happy!

The Spring Boot application gives a better and more compact hint of what has gone wrong:

no String-argument constructor/factory method to deserialize from String value ('{<EOL> "bucket": {{bucket}},<EOL> "document": "greetings.csv"<EOL>}')]

I have tried by hardcoding the values of those two variables on the modeller, and thus effectively bypassed the step of process variable substitution (using “{{ … }}”). Then the workflow runs till the end without a whimper.

Obviously, I am making some mistake in the syntax that passes process variables to HTTP payload.

BTW, I have used the following combinations in the Request Body:

{
  "bucket": ${bucket},
  "document": ${document}
}
{
  "bucket": $bucket,
  "document": $document
}
{
  "bucket": bucket,
  "document": document
}

None of these, works (has the same problem).

Could someone please give me a hint, where I am going wrong?

PS: I have referred to this post but it doesn’t mention the final answer.

The {{}} and ${} format are C7 variable substitution formats.
the last version that you posted /should/ work.

{
  "bucket": bucket,
  "document": document
}

Try setting that into a single variable earlier in your BPMN flow, so you can confirm that it’s generating good JSON and then send just that placeholder JSON variable to your REST Connector

The reason it doesn’t have an answer is that the OP of that thread abandoned it :frowning: They were asked some questions that weren’t answered – and we can’t help if we don’t know what we’re working with.

I understand that. No problem.

I have mentioned it to indicate that I have searched for an existing answer!

My Question is very similar. I need help. :blush:

Could you please elaborate a bit?

Try using a script task to set a BPMN variable (eg. sample_post_payload ) as the value you want the request body to be (eg.

{
"bucket": bucket,
"document": document
}

Then in the REST Connector, simply put the sample_post_payload into the request body. that way, in Operate, you can see what the payload actually was.

Thanks for the hint.

Well, I haven’t used a Script task in the strict sense. I have used Camunda Modeller’s Payload textbox, but I have explicitly made it to use FEEL expression, by pressing on the fx button at its top. And, the workflow runs to the end, smoothly.

What this means is despite the contents of the ‘Payload’ field, being exactly the same between fx activated and not activated, the Newline etc. are translated when fx is activated. The resultant JSON - which reaches the external HTTP service (outbound HTTP Connector’s other end) - is formed correctly.

For the ‘Request Body’, fx is activated. As a result, the script inside - which is essentially a JSON structure - is interpreted correctly and JSONified correctly before being served to the external HTTP endpoint. The same thing, I had created during my earlier efforts, but without activating fx (I had just typed in with newlines etc., to format it). Even though the contents were exactly the same, the interpretation of the payload was incorrect.

So, the takeaway for me is that for describing how process variables should be used as parameters to external calls and how the return values from those external calls should be held inside process variables (for further processing), one should always use FEEL expression .

Thank you, @GotnOGuts ! I appreciate.

2 Likes

I had a feeling that it was something like that, but missed the blue = flag was missing in your original screenshot.

Yes, to substitute variables, you need to start it with = (or press the fx button)

THANK YOU for posting the solution to your issue!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.