File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Empty request body in REST service

 
Sam Mc Kee
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a REST service that accepts JSON in the request body. The method is defined as follows:



In the body of the request is a list of JSON objects representing ShoppingListItem objects, and this works fine. However, I would expect it also to work if the request body is empty--that the items variable would simply be null. However I get a 500 error before it even reaches my service when I post a request with an empty body.

Is this behavior normal/expected?

Thanks!
Sam

 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are using Jersey, and in that case Jersey won't be able to find the matching method to call.
As far as I know, this is expected but I would wait for some experts to shed some more lights here.
 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer was wrong and I guess I didn't read your post well.
I was thinking about the uri and not the POST message being blank.

As per the REST architecture, you will call POST only if you want to UPDATE the resource.
And in your case you are calling POST without any payload.
This is an interesting thing. Let me try this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic