Spring MVC Controller: Redirect without parameters being added to my url

In Spring 3.1 a preferred way to control this behaviour is to add a RedirectAttributes parameter to your method: @RequestMapping(“save/”) public String doSave(…, RedirectAttributes ra) { … return “redirect:/success/”; } It disables addition of attributes by default and allows you to control which attributes to add explicitly. In previous versions of Spring it was more … Read more

RESTful POSTS, do you POST objects to the singular or plural Uri?

Since POST is an “append” operation, it might be more Englishy to POST to /products, as you’d be appending a new product to the existing list of products. As long as you’ve standardized on something within your API, I think that’s good enough. Since REST APIs should be hypertext-driven, the URI is relatively inconsequential anyway. … Read more

Proper route for checking resource existence in a RESTful API [closed]

HEAD is the most effecient for existence checks: HEAD /users/{username} Request a user’s path, and return a 200 if they exist, or a 404 if they don’t. Mind you, you probably don’t want to be exposing endpoints that check email addresses. It opens a security and privacy hole. Usernames that are already publicly displayed around … Read more

Confusion Between Noun vs. Verb in Rest URLs

Some snippets from the REST API Design Rulebook about different resource types: Document A document resource is a singular concept that is akin to an object instance or database record. Example: http://api.soccer.restapi.org/leagues/seattle/teams/trebuchet Collection A collection resource is a server-managed directory of resources. Clients may propose new resources to be added to a collection. However, it … Read more

How to add method description in Swagger UI in WebAPI Application

This is well documented in the project: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#include-descriptions-from-xml-comments Include Descriptions from XML Comments To enhance the generated docs with human-friendly descriptions, you can annotate controller actions and models with Xml Comments and configure Swashbuckle to incorporate those comments into the outputted Swagger JSON: 1 – Open the Properties dialog for your project, click the “Build” … Read more

How to access the services from RESTful API in my angularjs page?

Option 1: $http service AngularJS provides the $http service that does exactly what you want: Sending AJAX requests to web services and receiving data from them, using JSON (which is perfectly for talking to REST services). To give an example (taken from the AngularJS documentation and slightly adapted): $http({ method: ‘GET’, url: ‘/foo’ }). success(function … Read more