Can't get a PUT request to work using the REST API through CORS.

I am trying to complete a task using the REST API. I have added CORS to the bonita server as described here . I am able to successfully use GET and POST with the API.

I first login to http://localhost:8082/bonita/loginservice which is successful.

When doing a PUT to (http://localhost:8082/bonita/API/bpm/humanTask/80006) Bonita is telling me that this method is not allowed.

Remote Address:127.0.0.1:8082
Request URL:http://localhost:8082/bonita/API/bpm/humanTask/80006
Request Method:OPTIONS
Status Code:405 Method Not Allowed
Request Headersview source
Accept:/
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:PUT
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:8082
Origin:http://localhost:4200
Pragma:no-cache
Referer:http://localhost:4200/tasks/changeEmail/80006
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36
Response Headersview source
Content-Length:75
Content-Type:text/plain
Date:Wed, 03 Dec 2014 02:44:37 GMT
Server:Apache-Coyote/1.1

The ID in the request (80006) is the results of http://localhost:8082/bonita/API/bpm/humanTask?f=user_id%3D103

[{"displayDescription":"","executedBySubstitute":"0","processId":"6655478004102162725","state":"ready","rootContainerId":"4003","type":"USER_TASK","assigned_id":"","assigned_date":"","id":"80006","executedBy":"0","caseId":"4003","priority":"normal","actorId":"402","description":"","name":"Step1","reached_state_date":"2014-12-03 13:44:29.104","displayName":"Step1","dueDate":"2014-12-03 14:44:29.086","last_update_date":"2014-12-03 13:44:29.104"}]

Anyone know why this is?

2 Likes

I got this working, turns out http://software.dzhuvinov.com jar does not support REST by default.

Had to add the following config to BONITA_INSTALL_DIR/workspace/tomcat/conf/web.xml:

CORS com.thetransactioncompany.cors.CORSFilter
<init-param>
  <param-name>cors.supportedMethods</param-name>
  <param-value>GET, HEAD, POST, PUT, DELETE, OPTIONS</param-value>
</init-param>
CORS /*