Service task PATCH/POST Call to external application

Dear all,

I would like to write back a status information of my camunda workflow to an application which is located somewhere else (in my Cloud Foundry environment). I thought to do that via a PATCH/POST request to my target URL.

So far I found two apporaches to implement that:

  1. via connector task as described here
    CAMUNDA connectors. CAMUNDA GET and POST Request explained along with example. CAMUNDA REST API’s - YouTube

  2. via external task as described here
    Camunda Platform Tutorial: Setting Up and Triggering Timer and BPMN Error Events in Camunda Run - YouTube

I would favor the second approach and “just” give it a second Client which is my target application and there invoke the post request including my variables which I want to write back. Is that approach recommendable or should I rather go with the first/another one?

Best Regards
Max

If you’re looking to make a rest call from camunda to an external system your best bet is to the check out this project:

it’ll show the pros and cons of each approach and also an example in code of how to do it

Thank you :slight_smile:
I am trying to implement this via connector and added the necessary dependencies for using the connector in my pom.xml file.

The same POST Call from Postman works fine but inside camunda this can not be invoked to some reason.

I am missing the Variable Assignment Type “Text”. Could that be the potential error cause? Do you have an idea why this is missing?


never the less, it looks like the Type “string or Expression” provides the same functionality.

Best Regards
Max

The POST Call works fine.
After approving the workflow I now want to write everything inside my context (basically all variables) back to my app instance. Therefore I use a PATCH Call. I would like to write back the “status_wf” variable to my target App ( there the field is called equally "status_wf) The question in my scenario is - how can I assign either all variables from my workflow into my payload (Variable Assignment Values) or only the status_wf so it only updates the status_wf field in my target app?

The PATCH Request to the same URL in Postman works fine with the body {“status_wf” : “approved”}. How do I apply this body equally to my payload inside my service connector http task?

${variables} does not work - neither does ${status_wf} or ${variables.status_wf} or {“status_wf” : “approved”} work

I would be very thankful for any feedback!

Best Regards

response received by any any combination: e.g.
JSON.stringify({“staus_wf” : “approved”}) within an inline script

image

Your error says you have a problem in your header configuration.

You should have a Script for your payload input.
Then create a JS object with your status_wf property, and have the script return a stringified json object.

Hi @StephenOTT

I tried many combinations within Type: inline Script and Format: javascript
could you perhaps provide some template codesnippet for the script part? like {“status” : “approved”}

Best Regards
Max

see:

Hi @StephenOTT
Thanks for the response!

I followed your advises: please see my header and payload which is a copy of my postman Headers and Body ( the body in Postman is: {“status_wf”:“approved”} ). In Postman it works fine.

camunda_headers

camunda_payload

I am still receiving the error:

{“error”:{“code”:“400”,“message”:“Invalid value “undefined” in content-type header. The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined.”}}

I am wondering what the cause of this is. the payload seems fine. If I am missing something in my headers I am wondering what it is. Do you have any idea?

Best Regards
Max

easy solution was found as I missed an “s” in my header variable name. Of course it had to be “headers” instead of “header”… :wink:

1 Like