cancel
Showing results for 
Search instead for 
Did you mean: 

Leveraging the REST API- problem with CLAIM/COMPLETE tasks

yury_h
Champ in-the-making
Champ in-the-making
Hi there,

I have been playing around with the REST API. Getting tasks, etc. worked fine.
But then I got into trouble trying to claim or complete a task.

This is the PUT request I am sending:
PUT /activiti-rest/service/task/111/claim HTTP/1.1

And this is the response I am getting:
d1f
{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "06080039 Wrapped Exception (with status template): A JSONObject text must begin with '{' at 1 [character 2 line 1]", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 06080039 Wrapped Exception (with status template): A JSONObject text must begin with '{' at 1 [character 2 line 1]",
 
  "callstack" :
  [
       ""      ,"org.activiti.impl.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]"
      ,"org.activiti.impl.json.JSONTokener.syntaxError(JSONTokener.java:423)"
      ,"org.activiti.impl.json.JSONObject.<init>(JSONObject.java:184)"
      ,"org.activiti.impl.json.JSONObject.<init>(JSONObject.java:311)"
      ,"org.activiti.rest.util.ActivitiWebScript$ActivitiWebScriptBody.<init>(ActivitiWebScript.java:395)"
      ,"org.activiti.rest.util.ActivitiWebScript.getBody(ActivitiWebScript.java:150)"
      ,"org.activiti.rest.api.tasks.TaskOperationPut.executeWebScript(TaskOperationPut.java:44)"
      ,"org.activiti.rest.util.ActivitiWebScript.executeImpl(ActivitiWebScript.java:68)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)"
      ,"org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:307)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:178)"
      ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)"
      ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:717)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)"
      ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)"
      ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)"
      ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)"
      ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)"
      ,"org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)"
      ,"org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)"
      ,"org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)"
      ,"java.lang.Thread.run(Thread.java:637)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 06080039 Wrapped Exception (with status template): A JSONObject text must begin with '{' at 1 [character 2 line 1]"
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:731)"

  ],
 
  "server" : "Alfresco - v1.0.0 (Milestone 3 349) schema 1,000",
  "time" : "Jul 8, 2010 11:44:26 PM"



Is this a bug? (I am using Alpha3).
2 REPLIES 2

yury_h
Champ in-the-making
Champ in-the-making
After doing some research and comparing the PUT Method HTTP requests of the Activiti-Explorer application with those I generate in my app, I found the answer to be very simple.

This is not a bug but something one needs to know: the PUT Request body must contain en empty JSON object = "{}". Because the way Activiti REST service is implemented it always checks the request body,  and if it is empty (content length = 0), you will get the above exception which I got.

Maybe the implementation should be changed to ignore the body, if it is not needed, like in this case (claim or complete) task. But it is definitely something we can live with. Just the documentation should be completed in that specific part.

tombaeyens
Champ in-the-making
Champ in-the-making
david is going to look at that next week