Spring @ExceptionHandler does not work with @ResponseBody

Your method @ExceptionHandler(IllegalArgumentException.class) public @ResponseBody Map<String, Object> handleException(final Exception e, final HttpServletRequest request, Writer writer) does not work because it has the wrong return type. @ExceptionHandler methods have only two valid return types: String ModelAndView. See http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html for more information. Here’s the specific text from the link: The return type can be a String, which … Read more

How to expose a RESTful Web Service using Meteor

I did a full write-on on this in Meteorpedia: http://www.meteorpedia.com/read/REST_API The post reviews all 6 options for creating REST interfaces, from highest level (e.g. smart packages that handle everything for you) to lowest level (e.g. writing your own connectHandler). Additionally the post covers when using a REST interface is the right or wrong thing to … Read more

REST Content-Type: Should it be based on extension or Accept header?

Both are valid. Quote from xml.com: A resource may have more than one representation. There are four frequently used ways of delivering the correct resource representation to consumers: Server-driven negotiation. The service provider determines the right representation from prior knowledge of its clients or uses the information provided in HTTP headers like Accept, Accept-Charset, Accept-Encoding, … Read more

Querystring in REST Resource url

There is no difference between the two URIs from the perspective of the client. URIs are opaque to the client. Use whichever maps more cleanly into your server side infrastructure. As far as REST is concerned there is absolutely no difference. I believe the reason why so many people do believe that it is only … Read more

RESTful way to create multiple items in one request

I believe that another correct way to approach this would be to create another resource that represents your collection of resources. Example, imagine that we have an endpoint like /api/sheep/{id} and we can POST to /api/sheep to create a sheep resource. Now, if we want to support bulk creation, we should consider a new flock … Read more