users@jersey.java.net

[Jersey] Re: Best way to diagnose a 400 error on POST

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Fri, 10 Dec 2010 11:25:11 -0800 (PST)

Hmm..I'd say make sure the client Content-Type is set correctly..but that would probably be a different response code (405? forget the code for media type not supported). If it's not even getting inside the method.. can you try using XML just to rule out if it is indeed your json format or not?

You can also add a filter before the methods get called, and check there to see what is going on perhaps.


--- On Thu, 12/9/10, Jason Erickson <jason_at_jasonerickson.com> wrote:

From: Jason Erickson <jason_at_jasonerickson.com>
Subject: [Jersey] Best way to diagnose a 400 error on POST
To: users_at_jersey.java.net
Date: Thursday, December 9, 2010, 9:10 PM

Hi.  I have a REST method defined thus: @POST @Consumes(MediaType.APPLICATION_JSON) public Response addObservationSession(ObservationSession session, @Context UriInfo uriInfo) throws URISyntaxException  { .. do some stuff return Response.created(new URI("/" + session.getId())).build(); }
This is giving me a 400 error when I call it.  Clearly it doesn't like my JSON string, but it's hard for me to tell what's wrong with it (or if it's not the string, maybe it's the header or who knows).  I can't put a breakpoint in my code because it never gets to my code.  What's the best way to get a clue?