Camunda with variables in return

Hi everyone.
Please help me.
I have a Camunda process. I call this process using Camunda rest-engine with the endpoint “http://localhost:8080/engine-rest/process-definition/key/CRE_P_CashCredit_Scoring_ID_01/start”.

My Request:
{
“variables”: {
“ApplySource”: {
“value”: “branch”,
“type”: “string”
},
“CredSum”: {
“value”: 2000,
“type”: “Double”
}
},
“businessKey”: “Test”,
“withVariablesInReturn”: “true”
}

I want that request variables don’t return me. Only the process variables in Response variables
Process variables:
StopFactor
StopFactorReason
FinalOfferAmount

Hi @xxdadashov ,

I am not sure if I understood your issue correctly, but I will try to share my thoughts.

When creating a process instance with variables in return, then the call returns on the reaching the first transaction boundary, e. g. on reaching the first user task. All parts of the process that occurs before that first boundary will be executed synchronously. Then, the request returns with the latest variables at this time.

So, when I got you right, you are missing some variables from the process. Maybe these are set later in the process after your request returned?

Kind regards
Adagatiya

1 Like

Request:
{
“variables”: {
“ApplySource”: {
“value”: “branch”,
“type”: “string”
},
“CredSum”: {
“value”: 2000,
“type”: “Double”
}
},
“businessKey”: “Test”,
“withVariablesInReturn”: “true”
}

Response:
{
“links”: [
{
“method”: “GET”,
“href”: “http://localhost:8080/engine-rest/process-instance/af588d8a-486b-11ed-854a-f8b46ad6b842”,
“rel”: “self”
}
],
“id”: “af588d8a-486b-11ed-854a-f8b46ad6b842”,
“definitionId”: “ac051cc9-486b-11ed-854a-f8b46ad6b842”,
“businessKey”: “Test_003”,
“caseInstanceId”: null,
“ended”: true,
“suspended”: false,
“tenantId”: null,
“variables”: {

		"ApplySource": {
        "type": "String",
        "value": "filial",
        "valueInfo": {}
		},
		"CredSum": {
        "type": "Double",
        "value": 2000.0,
        "valueInfo": {}
		},
		"StopFactor": {
        "type": "Boolean",
        "value": true,
        "valueInfo": {},
		}
		"StopFactorReason": {
        "type": "String",
        "value": "Son iş stajı < 3",
        "valueInfo": {}
		}, 
		"FinalOfferAmount": {
        "type": "Null",
        "value": null,
        "valueInfo": {}
		}		
		
}

}

I want it to be like below:
Response:
{
“links”: [
{
“method”: “GET”,
“href”: “http://localhost:8080/engine-rest/process-instance/af588d8a-486b-11ed-854a-f8b46ad6b842”,
“rel”: “self”
}
],
“id”: “af588d8a-486b-11ed-854a-f8b46ad6b842”,
“definitionId”: “ac051cc9-486b-11ed-854a-f8b46ad6b842”,
“businessKey”: “Test_003”,
“caseInstanceId”: null,
“ended”: true,
“suspended”: false,
“tenantId”: null,
“variables”: {

		"StopFactor": {
        "type": "Boolean",
        "value": true,
        "valueInfo": {},
		}
		"StopFactorReason": {
        "type": "String",
        "value": "Son iş stajı < 3",
        "valueInfo": {}
		}, 
		"FinalOfferAmount": {
        "type": "Null",
        "value": null,
        "valueInfo": {}
		}		
		
	
}

}

Hi @xxdadashov ,

ah, you would like to exclude the variable you sent with your request. I do not think this is possible as they are process variables just as the ones you expect. Your only chance would be to explicitly remove them during process execution (e. g. using a script task), but I am not sure if that fits your requirement. As alternative you could develop your own api that does process instantiation and then filters the response variables to not include the request variables.

Kind regards
Adagatiya

1 Like

Hi @xxdadashov

If you are deploying your process applications as Java applications on the Camunda Run or Camunda Tomcat / WildFly distributions, you could add your own REST API and expose your own start operation.

From that custom API you can call the Camunda Java API to start the process, wait for it to reach wait state, collect the variables you want and only return those you want in your reply.

Hope that helps.

BR
Michael

1 Like