Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RESTful web services and status code philosophy

 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, for a GET specifying a record (or some such) that doesn't exist, the response has status code 404 (not found). That's easy.

But what about a PUT that fails because the user gave bad input?

404 doesn't seem to cut it. And there doesn't seem to be any other pre-defined status codes that don't already have some heavy HTTP semantics associated with them.

What's the appropriate return code?

Overall, what's the philosophy to choosing status codes for a RESTful service?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
But what about a PUT that fails because the user gave bad input?



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 doesn't make any sense.



Overall, what's the philosophy to choosing status codes for a RESTful service?



"Appendix B: The HTTP Response Code Top 42" from RESTful Web Services
 
Bear Bibeault
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peer!
    Bookmark Topic Watch Topic
  • New Topic