Assign task to a user using REST API

1,848 views
Skip to first unread message

gummy...@gmail.com

unread,
Sep 24, 2013, 7:37:32 PM9/24/13
to camunda-...@googlegroups.com
Hi everyone!

When a ask for some task definition, through the REST API (like http://localhost:8080/engine-rest/process-instance/166bee75-256a-11e3-8f83-c90b0dec1df8) it retrieve information about the task I asked for. But, if I want to assign that task to a user using following parameters

POST /engine-rest/task/166bee75-256a-11e3-8f83-c90b0dec1df8/assignee HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Cache-Control: no-cache

{"id":"anne.grant"}

it returns an error code ( 404 - Not found ) whit this description:
The requested resource (Could not find resource for relative : /task/166bee75-256a-11e3-8f83-c90b0dec1df8/assignee of full path: http://localhost:8080/engine-rest/task/166bee75-256a-11e3-8f83-c90b0dec1df8/assignee) is not available

So, now I'm wonder what goes wrong ... ? According with documentation, it's possible to assign a task to a user doing what I did but I don't know if there are something missing. So, if anyone can help me through this I will appreciate. Thanks!

thorben....@camunda.com

unread,
Sep 25, 2013, 3:10:19 AM9/25/13
to camunda-...@googlegroups.com, gummy...@gmail.com
Hi,

Your first request retrieves a process instance, so I assume 166bee75-256a-11e3-8f83-c90b0dec1df8 is a process instance id. That is why no such task exists. You can get a list of all available tasks using this method: http://docs.camunda.org/latest/api-references/rest/#task-get-tasks

I hope that solves your problem.

Cheers,
Thorben

thorben....@camunda.com

unread,
Sep 25, 2013, 3:30:57 AM9/25/13
to camunda-...@googlegroups.com, gummy...@gmail.com
In addition (telling from the error message), it seems that the task resource is not deployed properly. Could you post your deployment setup of camunda BPM platform and especially the REST API?
If you embed the resources in your own JAX-RS application (according to this section of the docs: http://docs.camunda.org/latest/api-references/rest/#overview-embedding-the-api), please make sure that you include the TaskRestServiceImpl class in it.

gummy...@gmail.com

unread,
Sep 25, 2013, 12:16:18 PM9/25/13
to camunda-...@googlegroups.com, gummy...@gmail.com
Hi Thorben...thank you for you answer!

And yes, I'm using embedding REST API on my own JAX-RS application and I do have included the TaskRestServiceImpl class on it as well as some other classes as explained in http://doc.camunda.org/latest/api-references/rest#overview-embedding-the-api reference. As a matter of facts, it was when I tried to probe my application that I detected that error. But then, I tried directly from deployed Camunda REST API (http://localhost:8080/engine-rest) and the same error was thrown.
You're right about process instance id isn't the same task id; but then, first I got the task list and the server returned something like this
Task Definition
{
"id": "166f49e3-256a-11e3-8f83-c90b0dec1df8",
"name": "Invoice",
"assignee": null,
"created": "2013-09-24T17:38:52",
"due": null,
"delegationState": null,
"description": null,
"executionId": "166bee75-256a-11e3-8f83-c90b0dec1df8",
"owner": null,
"parentTaskId": null,
"priority": 50,
"processDefinitionId": "process:1:6f1b59a3-2558-11e3-8f83-c90b0dec1df8",
"processInstanceId": "166bee75-256a-11e3-8f83-c90b0dec1df8",
"taskDefinitionKey": "invoice"
}

So, if I try to use the task id and assign the task to an user
POST /engine-rest/task/166f49e3-256a-11e3-8f83-c90b0dec1df8/assignee HTTP/1.1


Host: localhost:8080
Content-Type: application/json
Cache-Control: no-cache

{"id":"anne.grant"}

the server response with the same error ( 404 - Not found
The requested resource (Could not find resource for relative : /task/166f49e3-256a-11e3-8f83-c90b0dec1df8/assignee of full
path: http://localhost:8080/engine-rest/task/166f49e3-256a-11e3-8f83-c90b0dec1df8/assignee) is not available ) but there isn't any server side exception.

It is weird because I performed some other actions like add a group, update group profile, delete a group, create an user, update his profile information, start a process and all of them using deployed Camunda REST API and with no errors but when I try to assign some task is when the API doesn't work.

thorben....@camunda.com

unread,
Sep 25, 2013, 4:55:11 PM9/25/13
to camunda-...@googlegroups.com, gummy...@gmail.com
Hi,

This is indeed weird. You do not see an exception in your server logs, because it is an exception your JAX-RS runtime handles. A non-existing resource is typically not exceptional, but a common case.

To be able to track the problem down, I have some questions:
1. Do you see the same error when you issue GET /task/166f49e3-256a-11e3-8f83-c90b0dec1df8 ?
2. What version of the camunda classes jar are you using?
3. What JAX-RS implementation are you using your application with and what container is it running in?
4. What do you mean with "I tried directly from deployed Camunda REST API"? Did you try to deploy the camunda rest war file in your environment or did you try one of the prepackaged distributions from camunda.org?

I have a rough guess that there could be some issue, because the set assignee method is located in a sub-resource (class TaskResource) and not in the root resource (TaskRestServiceImpl). On the other hand you say that deleting a group works, which is pretty much the same case...

Best regards,
Thorben

gummy...@gmail.com

unread,
Sep 26, 2013, 5:57:52 PM9/26/13
to camunda-...@googlegroups.com, gummy...@gmail.com
Hi Thorben,

Here are my answers to your questions:

1. Do you see the same error when you issue GET /task/166f49e3-256a-11e3-8f83-c90b0dec1df8 ?

Nope, when I request task information by id it return the correct information I was expecting for.

2. What version of the camunda classes jar are you using?

7.0.0-alpha9

3. What JAX-RS implementation are you using your application with and what container is it running in?

I'm not quite sure about the implementation but I guess it's RESTEasy since I'm working with JBoss to build my application. As container I also use JBoss ( 7.1.3 )

4. What do you mean with "I tried directly from deployed Camunda REST API"?
Did you try to deploy the camunda rest war file in your environment or
did you try one of the prepackaged distributions from camunda.org?

I meant one of the prepackaged distributions from camunda.org. As a matter of facts, I downloaded prepackaged JBoss from camunda.org so now I have two servers (one for my own app and the other for camunda projects). I know that I can run both my own application and camunda project onto the same JBoss Server but I prefer to have them separated from each other.

Hope this can help. And thank you for taking some time to see this. Best regards!

thorben....@camunda.com

unread,
Sep 27, 2013, 3:03:35 AM9/27/13
to camunda-...@googlegroups.com, gummy...@gmail.com
Hi,

There's our issue: setting assignee was not yet part of alpha9. Please upgrade your camunda dependency to version 7.0.0-Final and it should work fine.:)
This is the corresponding ticket: https://app.camunda.com/jira/browse/CAM-1132

Cheers,
Thorben
Reply all
Reply to author
Forward
0 new messages