2

I'm using wildfly 10 and REST and have the following error:

08:15:19,827 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-22) RESTEASY002010: Failed to execute: javax.ws.rs.NotSupportedException: RESTEASY003065: Cannot consume content type

I have the following request:

http://localhost:8080/MyApp/rest/myService/test?data=%7B%22MyData%22:%7B%22id%22:%223d87e735-4f88-49bd-929b-5f2b646e853e%22,%22name%22:%22myname%22%7D%7D

--> parameter is:

data:{"MyData":{"id":"3d87e735-4f88-49bd-929b-5f2b646e853e","name":"myname"}}

My service:

@Path("/myService")
@Produces(MediaType.APPLICATION_JSON)
@Stateless
public class StammdatenRestRessource {

  @POST
  @Path("/test")
  @Consumes(MediaType.APPLICATION_JSON)
  public Response test(final MyData data) {
      System.out.println(data);
      return Response.ok().build();
  }
}

and my POJO:

@XmlRootElement
@Entity
public class MyData{

@Id
@Column(name = "ID")
private String id;

private String name;

public MyData() {
    id = UUID.randomUUID().toString();
}

// getters & setters
}

Any idea?

jobe
  • 325
  • 2
  • 14
  • 25
  • I haven't been able to find a single @Consumes annotation that works with RESTeasy. Everyone blames "the client", but resteasy chokes on javascript ajax calls from browser console that work for absolutely everything else. The only way to make it work is to take out the Consumes annotation – Alkanshel Jun 10 '16 at 00:35

3 Answers3

1

Make sure that you are sending a "Content-type" header with a value of "application/json":

curl -H 'Content-type: application/json' http://localhost:8080/MyApp/rest/myService/test?data=%7B%22MyData%22:%7B%22id%22:%223d87e735-4f88-49bd-929b-5f2b646e853e%22,%22name%22:%22myname%22%7D%7D

jpkroehling
  • 13,881
  • 1
  • 37
  • 39
0

The glaring point to me is the id field. the value "id" will not parse into a UUID object (you can try to call UUID.fromString() and see for yourself). take a "real" UUID value and see if this is the problem

here's one for ya "3d87e735-4f88-49bd-929b-5f2b646e853e"

Sharon Ben Asher
  • 13,849
  • 5
  • 33
  • 47
  • Thank you for the advice but i get the same error. I also tried to change the UUID to String. – jobe Jan 14 '16 at 08:59
0

Ok i found a solution. I have to put my json object in the request body and not the address.

jobe
  • 325
  • 2
  • 14
  • 25