cancel
Showing results for 
Search instead for 
Did you mean: 

How to create List and Map variables types using REST

penusila611621
Champ in-the-making
Champ in-the-making
Hi,

have one of the requriement where I need to create a variable on existing task using following rest URL.

POST http://hostnameSmiley Tongueort/activiti-rest/service/runtime/tasks/taskId/variables

In the body,
[
  {
    "name" : "listNames",
    "scope" : "local",
    "type" : "list",
    "value" : "ok"
  }
]


This is not working, somebody please advice me on how to create a variable types like List & Map using above rest calls.
7 REPLIES 7

penusila611621
Champ in-the-making
Champ in-the-making
Any idea on this please ??

trademak
Star Contributor
Star Contributor
You can read this blog post for information about custom variable types:

http://stacktrace.be/blog/2013/09/

Best regards,

penusila611621
Champ in-the-making
Champ in-the-making
HI Tijs Rademakers,

Have read the above blog post. I think the post demonstrating the example at high level. I am bit new to Activiti so not able to abstract where & how to make these changes. Any simple example is appreciated.

penusila611621
Champ in-the-making
Champ in-the-making
Now I have understood that I need to create CustomRestResponseFactory by extending RestResponseFactory in that need to override the method initializeVariableConverters method to accomodate my new RestVariableConverter to support List and Map.

I am not sure where should I keep CustomRestResponseFactory class so that all of my rest calls should use this class.

jbarrez
Star Contributor
Star Contributor
You add it to the classpath, and inject it into the Rest classes, as in the article:

ActivitiRestServicesApplication application = new ActivitiRestServicesApplication();
application.setRestResponseFactory(new CustomRestResponseFactory());

dparish
Champ in-the-making
Champ in-the-making
I tried to get this working and so far have not succeeded. It looks like how the rest webapp initializes has now changed.  Here's what I did. I put a activiti.cfg.xml in the rest webapp WEB-INF/classes like this:

<code>
<beans>
    <bean id="restResponseFactory" class="my.activiti.rest.CustomRestResponseFactory" />
</beans>
</code>
I've got the jar with my CustomRestResponseFactory (which extends RestResponseFactory) in the rest webapp's WEB-INF/lib

When I startup tomcat it doesn't look like my class is being injected.  Is there a better way to customize the rest api webapp that I'm missing?

I should add that I'm using the 5.16.4 release which changed the rest api from restlet's to Spring which may have an affect on what is going on here.

trademak
Star Contributor
Star Contributor
If you want to customise RestResponseFactory the best way is too clone the REST application and change the RestConfiguration class:

https://github.com/Activiti/Activiti/blob/master/modules/activiti-webapp-rest2/src/main/java/org/act...

Best regards,