SPIN/JACKSON-JSON-01007 error getting Process Variables!

I want to represent internally all my engine variables using JSON. To do that, I added this line to my @PostDeploy annotated method:

	@PostDeploy
	public void onDeploymentFinished(ProcessEngine processEngine) {
		logger.info("Startup de server detectado !!");
		StandaloneProcessEngineConfiguration processEngineConfiguration = (StandaloneProcessEngineConfiguration) processEngine.getProcessEngineConfiguration();
		processEngineConfiguration.setDefaultSerializationFormat("application/json");
	}

So far so good !!

If I want to see the internal representation of a certain variable using Camunda CockPick, I see this:

Awesome ! No problem !

But … When I want to get that process variables:

http://localhost:8080/engine-rest/process-instance/b735fdf5-84b3-11e6-b0f1-3052cb7171b3/variables

I get this error:

{"type":"ProcessEngineException","message":"Cannot deserialize object in variable 'cuitsInfo': SPIN/JACKSON-JSON-01007 Cannot construct java type from string 'com.credicuotas.api.model.bpm.QuizDTO'"}

Any ideas ?

I forget !!

This is my DTO:

import java.util.HashMap;
import java.util.Map;

public class QuizDTO {

	private Map<Long,String> quizOptions = new HashMap<Long,String>();
	
	public QuizDTO() {
	}
	
	public QuizDTO(Map<Long, String> quizOptions) {
		this.quizOptions = quizOptions;
	}

	public Map<Long, String> getQuizOptions() {
		return quizOptions;
	}

	public void setQuizOptions(Map<Long, String> quizOptions) {
		this.quizOptions = quizOptions;
	}
}

Hi Maximiliano,

if you want to request the serialized value of the variables then set the {{deserializeValues}} parameter to {{false}} (is {{true}} per default).
Your request should look like this:
http://localhost:8080/engine-rest/process-instance/b735fdf5-84b3-11e6-b0f1-3052cb7171b3/variables?deserializeValues=false

Greets,
Chris

2 Likes

It worked perfectly, but I still have two problems:

  1. Is not returning the pure json content
  2. Is there a way to return a specific variable deserialized insted of retuning EVERYTHING ? Im reading the doc and doesnt seems to be a way to do that.

Best again !

Hi Maximiliano,

no it is not possible. But you can do it by yourself.

Create a new REST resource for example /history/variable-instance/compact, that reads the historic variables and put them into a new DTO class.
That new DTO for example called NewHistoricVariableDTO contains only the properties value, type and valueInfo.
After the creation, of the NewHistoricVariableDTO objects, put them in a map of variables with the variable name as key and return them. The result can be for example look like this:

[ 
  "var1": {
    "type": "String",
    "value": "Some value",
    "valueInfo": {}
  }
]

That will be the same representation like in the other resources.
See the documentation for this.

Hope it helps.

Best regards,
Chris

Isn’t it just https://docs.camunda.org/manual/7.5/reference/rest/process-instance/variables/get-single-variable/ what you are looking for?

Yes, but it throws an exception because that variable is not correctly serialized. But dont worry, I did what you detail before and works perfectly. Thanks !