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

Reply via email to