Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem using the Activiti Rest web services
    primarykey
    data
    text
    <blockquote> <p>Edit: to simplify my question, has anyone managed to communicate with Activiti using rest?, and if so could you be kind to post your code. thanks.</p> </blockquote> <p>I've been struggeling for a while to login to Activiti using Rest. I followed the api guides and implemented the following</p> <p>Code:</p> <pre><code>package demo; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.core.util.MultivaluedMapImpl; import com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider; public class Aloha { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Client client = Client.create(); WebResource webResource = client .resource("http://localhost:8080/activiti-rest/service/login"); MultivaluedMap&lt;String, String&gt; formData = new MultivaluedMapImpl(); formData.add("userId", "kermit"); formData.add("password", "kermit"); ClientResponse response; try { response = webResource.type("application/x-www-form-urlencoded") .post(ClientResponse.class, formData); // webResource.accept(MediaType.TEXT_PLAIN_TYPE).post(ClientResponse.class, // formData); System.out.print(response.toString()); } catch (UniformInterfaceException ue) { System.out.print(ue.getMessage()); } } } </code></pre> <p>As you can see I am using Jersey to consume the webservice, and here is the response I am getting all time:</p> <p>Quote:</p> <pre><code>POST http://localhost:8080/activiti-rest/service/login returned a response status of 415 Unsupported Media Type </code></pre> <p>Please could you point out what I am doing wrong here?</p> <p>Please note that when I replace the type with "application/json" i get the follow error:</p> <p>Code:</p> <pre><code>Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.core.util.MultivaluedMapImpl, and MIME media type, application/json, was not found at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:563) at demo.Aloha.main(Aloha.java:32) Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class com.sun.jersey.core.util.MultivaluedMapImpl, and MIME media type, application/json, was not found at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:288) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:204) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147) ... 5 more </code></pre> <p>Many Thanks,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload