I'm trying to save a new variable to my process via REST API,
but when I run the POST, the console shows me the following error:
response.body({"message":"Bad request","exception":"Failed to serialize to a RestVariable instance"})
MY CODE:
String name = "variable";
String type = "string";
String value = "value";
//org.activiti.rest.service.api.engine.variable.RestVariable
RestVariable var = new RestVariable();
var.setName(name);
var.setType(type);
var.setValue(value);
//SPRING RESTOPERATION
restOperations.postForObject(http://urlserver:8080/activiti-rest/service/runtime/process-instances/512551/variables, var, String.class);
Regards!
Solved! Go to Solution.
update my code for:
List<Map<String, String>> maps = new ArrayList<>();
Map<String, String> map = new HashMap<String, String>();
map.put("name", "variable");
map.put("type", "string");
map.put("value", "value");
maps.add(map);
String json = new Gson().toJson(maps);
this worked!
Regards!
Because RestVariable class does not implement Serializable interface.
Activiti/RestVariable.java at master · Activiti/Activiti · GitHub
update my code for:
List<Map<String, String>> maps = new ArrayList<>();
Map<String, String> map = new HashMap<String, String>();
map.put("name", "variable");
map.put("type", "string");
map.put("value", "value");
maps.add(map);
String json = new Gson().toJson(maps);
this worked!
Regards!
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.