• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Empty request body in REST service

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic