Ah, sorry, didn't read closely enough. Yes, it does seem like an
inappropriate response code.

--tim

On Mon, Nov 29, 2010 at 11:02 AM, <[email protected]> wrote:

> Hi.
>
> I did actually put malformed json on pourpose.
>
> My point goa; to show if I send the right mime type (json) and malformed
> content, the return code should be 400 while in fact it is 415.
>
> Thanks for your reply.
> -teo
>
> > You're using invalid JSON in the entity. Try something like -d
> > '{"garbage":1}' (single-quotes are delimiters for shell, double-quotes
> are
> > part of the content. Or maybe just -d '1' -- that should be a valid JSON
> > value, too.
> >
> > It does seem a shame that JSON requires double-quotes around the keys,
> but
> > that's how it is.
> >
> > --tim
> >
> > On Mon, Nov 29, 2010 at 5:56 AM, <webpost at tigris dot org> wrote:
> >
> > > Hi.
> > >
> > > I'm receiving an unexpected 415 when using restelt 2.1 with jackson.
> I've
> > > started using restlet only recently, so I may well be the cause of the
> > > problem.
> > >
> > > Case:
> > > When posting valid content type but malformed body, I expect 400 "Bad
> > > Request". Instead I'm receiving 415 "Unsupported Media Type". Quoting
> from
> > > "RESTful web services":
> > >  "[400 Bad Request] It’s commonly used when the client submits a
> > > representation along with a PUT or POST request, and the representation
> is
> > > in the right format, but it doesn’t make any sense." "[415 Unsupported
> Media
> > > Type] If the client sends a document that’s got the right media type
> but the
> > > wrong format (such as an XML document written in the wrong vocabulary),
> a
> > > better response is the more generic 400 (“Bad Request”)"
> > >
> > > Java code:
> > > @Post("json")
> > > public Project create(Project project) {
> > >
> > > Test:
> > > $ curl -i -XPOST -H 'content-type: application/json' -d '{garbage}'
> > > http://localhost:8080/projects
> > > HTTP/1.1 415 Unsupported Media Type
> > >
> > > Java stack trace:
> > > WARNING: Unable to parse the object with Jackson.
> > > org.codehaus.jackson.JsonParseException: Unexpected character ('g'
> (code
> > > 103)): was expecting double-quote to start field name
> > >
> > > Is there a way to change fix behaviour and keep using jackson?
> > >
> > > Any help is greately appreciated,
> > > thanks!
> > >
> > > Matteo Caprari
> > > matteo.caprari on google mail
> > >
> > > ------------------------------------------------------
> > >
> > >
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2686427
> > >
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2686491
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2686518

Reply via email to