RESTFul architecture best practices

| By Webner

1. Restful web service has its specific set of standard methods like: GET, POST, DELETE, PUT, OPTIONS. We should use HTTP methods as per standard. For example: use “Delete” method to delete the resource not for any other task.
2. We should return valid HTTP response code for each and every request to provides exact status of the request on server side. The HTTP standard provides a number of status codes to describe the return values.
3. Proper exception handling should be done in the web service code. Proper error messages should be returned in the response.
4. Json return type REST web service are mostly used unless it is explicit requirement of the application to return XML. Allow client to switch to them by changing the Accept-Header in HTTP request body.
5. The response returned by web services should be self-explanatory.
6. URLs should be in human readable format. For example: /application/?name=users&value=1 such url should be avoided and can be replaced as: /application/users/1
7. The data returned as XML/JSON should be structured properly.
8. If you are using json request/response data type, you can easily get Request-Response variable names. Let’s see the below example:

//variable Declaration
private String offerDescription;

@JsonProperty(value ="description")
	public String getOfferDescription() {
		return offerDescription;

Using the above syntax you can map “description” key in the json request to
9. Always use proper version number to release your api.

Leave a Reply

Your email address will not be published. Required fields are marked *