cancel
Showing results for 
Search instead for 
Did you mean: 

[REST] Submitting typed variables

npasquetto
Champ in-the-making
Champ in-the-making
Hi, in chapter 15 of activiti user guide on the "Start Process Instance" section, I've read:

Note that if a value is submitted as true (instead of "true") it will be treated as a Boolean even if no descriptor is used. The same is also valid for number, i.e., 123 will become an Integer but "123" will become a String (unless a descriptor is defined).

but if I submit a value without the " symbol (e.g. a long value) the variable isn't read by the rest web application.

It's that a desired behavior? What is the correct way to send a long value?

Thanks in advance!
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
Could you post the json you submit?

npasquetto
Champ in-the-making
Champ in-the-making
Hi Joram,
Could you post the json you submit?
if I submit something like:
{"myEntityID":462,"myCustomData":"hello world"}only myCustomData will be available as execution variable, but if I submit something like:
{"myEntityID":"462","myCustomData":"hello world"}also myEntityID will be available, as a String.

Probably only text values are read from json requests by the Restlet based rest webapp. Could it be?

frederikherema1
Star Contributor
Star Contributor
Read our userguide on form-properties.

You an type the properties you submit:

<userTask id="task">
  <extensionElements>
  
    <activiti:formProperty id="duration" type="long"/>

  </extensionElements>
</userTask>

npasquetto
Champ in-the-making
Champ in-the-making
Frederik, thank you for your response!

Read our userguide on form-properties.

You an type the properties you submit:

<userTask id="task">
  <extensionElements>
  
    <activiti:formProperty id="duration" type="long"/>

  </extensionElements>
</userTask>

That's ok, but when i submit additional variables on a start process instance phase through the REST API, only text data will be evaluated and stored as process variables. Probably the same thing happen in the TaskOperation REST API.

PS: at the beginning of "External form rendering" section, user guide say that "The API also allows for you to perform your own task form rendering outside of the Activiti Engine" but probably means "outside of the Activiti Explorer"

frederikherema1
Star Contributor
Star Contributor
Sorry for the misunderstanding.
Indeed, the rest-methods don't expose the form-service but just accept the properties and uses their string-values. The same applies for starting a workflow.
Ideally, starting a workflow through the form-service should be possible through our REST-service. This shouldn't be too hard, since the value-conversion is done in
the engine itself, we can just chuck in all json-properties to the submitStartForm() instead.

Perhaps you're willing to contribute these additional REST-resources to the activiti-project?

npasquetto
Champ in-the-making
Champ in-the-making
Oh!
Sorry for the misunderstanding.
No problem Smiley Happy
Indeed, the rest-methods don't expose the form-service but just accept the properties and uses their string-values. The same applies for starting a workflow.
Yes, but I don't understand why the server accept only text values, there is some reason?
Ideally, starting a workflow through the form-service should be possible through our REST-service. This shouldn't be too hard, since the value-conversion is done in the engine itself, we can just chuck in all json-properties to the submitStartForm() instead.
We can do it simply by improving the corrent Start Process Instance and Perform Task Operation REST-services, correct?
Perhaps you're willing to contribute these additional REST-resources to the activiti-project?
We can think about it!

frederikherema1
Star Contributor
Star Contributor
The existing "start process" and "complete task" rest-calls should stay as they are.

2 new rest-resources should be added, having similar behavior to the two existing ones, but instead of calling startProcessInstance() and completeTask() they should be calling submitStartForm() and submitTaskForm() on the form service.

npasquetto
Champ in-the-making
Champ in-the-making
The existing "start process" and "complete task" rest-calls should stay as they are.

2 new rest-resources should be added, having similar behavior to the two existing ones, but instead of calling startProcessInstance() and completeTask() they should be calling submitStartForm() and submitTaskForm() on the form service.

OK, thank you, now I understand.

I assumed to improve the current tasks to maintain a certain parallelism between the Activiti Explorer and the REST API. In the Explorer you take the same way to start a process (or complete a task) with or without form properties, so I thought it was desirable to have a similar behavior in the REST API, with a single method. But probably it's not a correct approach.