Best Practice for API Call Pre/Post Processing in BPMN

In a BPMN flow, when using REST/SOAP connectors, how should I handle preparing the API body beforehand and updating process variables from the API response?

What is the best practice for managing pre/post-processing steps? Should I:

  1. Use a Call Activity to invoke a subprocess that handles both pre/post steps separately (Fig.1)?
  2. Implement everything within a single Service Task (Fig.2)? (Note: In this approach, it’s not possible to use Camunda REST connectors.)

Additionally, what’s the best way to structure similar API calls inside a regular Service Task while keeping the flow clean and maintainable?

Would appreciate any best practices or references. Thanks!

Ideally this should be done in a single task. Can you explain what you see as the limitations to that approch?

The limitation with using the Camunda REST connector (Fig.1.1) is that it doesn’t allow for pre-processing (preparing the API body) or post-processing (validating/updating variables from the response) within the same task. That’s why I need a setup like Fig.1.1 with separate steps.

How can I implement this logic inside a single task while still handling pre/post-processing effectively?

You can minipulate process variables via FEEL in order to create the correct format needed for the request directly in the related fields.

Result expressions can also be used as part of the connector to parse the response and create new variables as needed.

Can you give some specific details on the variable processing you need to do and maybe I can show exactly how to do it.

2 Likes

The best practice to maintain in regular service task and process through @Jobworker to avoid huge data flow within process and return the required data under output variable for next step payload.

Connector also have limitation on throw bpmn error or delegate the request task to another handler incase of exception.

1 Like

In my opinion (and it’s just an opinion), this Call Activity is basically what a Connector does. If you’re doing the same type of formatting, calling, returning on a regular basis, then writing your own working and building the templates to make if a custom connector (I can’t remember if you can register custom connectors for SaaS, but the blog post suggests it’s possible)

This makes it easy for your modelers (eg. BA, Business Users) to use your specific company processes in the exact way you want them to

1 Like

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