/task/create Rest API method doesn't work

581 views
Skip to first unread message

mas1...@gmail.com

unread,
Feb 7, 2016, 5:09:16 AM2/7/16
to camunda BPM users
Hello,

I'm trying to execute `POST /task/create` Rest API method (https://docs.camunda.org/manual/7.3/api-references/rest/#task-create-task), but it doesn't work.
The error message is "HTTP/1.1 405 Method Not Allowed" and it seems like that POST method isn't allowed.
Could you please tell me how to avoid this problem?

My environment is as bellow:
- camunda BPM platform version: 7.3.0
- Apache Tomcat Server version: 7.0.62

The command and response I'm trying is as bellow:

$ curl 'http://localhost:8080/engine-rest/task/create' \
> --request POST \
> --data 'name=MyTask' \
> --data 'description=Thishavetobedoneveryurgent' \
> --data 'assignee=demo' \
> --data 'owner=demo' \
> --verbose
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /engine-rest/task/create HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 75
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 75 out of 75 bytes
< HTTP/1.1 405 Method Not Allowed
< Server: Apache-Coyote/1.1
< Allow: HEAD, GET, OPTIONS, PUT
< Content-Length: 0
< Date: Sun, 07 Feb 2016 09:44:28 GMT
<
* Connection #0 to host localhost left intact


(For environmental issue check,) the following works:

$ curl 'http://localhost:8080/engine-rest/task/count' \
> --verbose
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /engine-rest/task/count HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Cache-Control: no-cache
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Sun, 07 Feb 2016 09:40:50 GMT
<
* Connection #0 to host localhost left intact
{"count":15}

thorben....@camunda.com

unread,
Feb 8, 2016, 3:35:49 AM2/8/16
to camunda BPM users
Hi,

Make sure to your request's Content-Type header to application/json and to provide a JSON object that follows the request specification in the docs in the request's body.

Cheerrs,
Thorben

Sebastian Menski

unread,
Feb 8, 2016, 3:46:13 AM2/8/16
to camunda BPM users
Hi,

the problem is that you are sending a form POST but the endpoint requires a JSON request object. Try this:

$ curl http://localhost:8080/engine-rest/task/create -H "Content-Type: application/json" -d '{"name": "MyTask", "description": "Thishavetobedoneveryurgent", "assignee": "demo"}' -v
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /engine-rest/task/create HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 83
* upload completely sent off: 83 out of 83 bytes
< HTTP/1.1 204 No Content
< Server: Apache-Coyote/1.1
< Date: Mon, 08 Feb 2016 08:42:17 GMT
* Connection #0 to host localhost left intact

Cheers,
Sebastian

Masaaki Inaba

unread,
Feb 8, 2016, 10:08:02 AM2/8/16
to camunda BPM users
Hi Thorben, Sebastian,

I am glad to inform you that the problem is now solved.
Thanks!!


2016年2月7日日曜日 19時09分16秒 UTC+9 Masaaki Inaba:
Reply all
Reply to author
Forward
0 new messages