WebAPI response

Hi,
I am developing an application that starts a process through webAPI. The process starts a java class that implements “JavaDelegate”. Is it possible to set additional data for the webAPI response?

public class ProcessRequestDelegate implements JavaDelegate {
  public void execute(DelegateExecution execution) throws Exception {
	  String user = execution.getVariable("username").toString();
	  String pass = execution.getVariable("password").toString();
  }
}

Best regards
Fabio

Hi Fabio,

It’s not exactly clear, what you are after.

  1. Can you please post a simple process model as an example to discuss?
  2. What do you mean with webAPI? The REST API provided by Camunda or a custom API that you write around the Camunda Java API?
  3. Can you elaborate on the use case?

Cheers,
Thorben

Hi thorben,
this is the code i use to call camunda rest API:

public ProvaCamundaPost() {
            var prova = {
                "variables": {
                    "username": { "value": "admin", "type": "String" },
                    "password": { "value": "admin", "type": "String" }
                } };
            return this.httpService.post('http://localhost:8080/engine-rest/process-definition/key/login-prova-2/submit-form',
                JSON.stringify(prova),
                {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }
            ).then((response: any) => {
                    var prova = null;
                });
        }

I would like to have custom data in the payload of the response, as example processDuration or DB retrived data. is it possible?

next the process that i have created to test it:

Thanks for your support
Fabio

Hi @balduzzi,

Thanks for the additional details.

The submit form REST API does not return a response that allows you to add custom data (e.g. process variables). As an alternative, you could either make two requests in the frontend (first submit form, then query for variables) or you could implement a custom REST API that uses the process engine Java API and makes the two requests on server side. With the first variant, you’ll have two transactions in the backend, with the second variant, you could implement it in a way that you’ll have a single transaction.

Cheers,
Thorben