What’s Webapi REST service?Interface constraints in Webapi

First I will explain what is REST?REST is nothing but the expansion of REpresentationl State Transfer. Will discuss what is meant by REST, it is an architectural pattern for creating an API that uses HTTP as its underlying communication method.Web API is the technology by which you can expose data over HTTP following REST principles.Here am describing What is Webapi REST service?Interface constraints in Webapi.

These are the key points which we have to take care while creating the Webapi

Resources – Addressable resources to define the structure of the API. These are the URLs you use to get to pages on the web.A URL is nothing but a Resource.

Request Verbs – A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there are many other verbs available including things like POST, PUT and DELETE.

Request Headers – These are additional instructions that are sent with the request. These might define what type of response is required or authorization details.

Request Body – Data that is sent with the request. For example a POST will required some data which is typically sent as the request body in the format of JSON or XML.

Response Body – This is the main body of the response. If the request was to a web server, this might be a full HTML page, if it was to an API, this might be a JSON or XML document.

Response Status codes – These codes are issues with the response and give the client details on the status of the request.

REST has 4 interface constraints. I am giving  a quick summary:

Identification of resources
Each resource has a URI and is access through a defined set of HTTP methods (GET, PUT, POST, DELETE)

Manipulation of resources through representations
Each resource can have one or more representations. Such as application/xml, application/json, text/html, etc. Clients and servers negotiate to select representation.

Self-descriptive messages
Requests and responses contain not only data but additional headers describing how the content should be handled. Such as if it should be cached, authentication requirements, etc.

Hypermedia as the engine for application state
I’m going to focus on the last interface constraint Hypermedia as the engine for application state because I think there is a lot to learn when it comes to hypermedia and why many services are not RESTful by violating this constraint.

Refer for how to create a sample Webapi.


IN Webapi Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.Choose Web API only when you want to expose your service to a broad range of clients including browsers, mobiles, iphone and tablets.

Leave a Reply

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