Tuesday, 11 April 2017

Methods in Rest Service

GET  Method:
This method can be used only to retrieves data from the server.
Example: GET request to retrieve the emp with id 110  from Server.
GET /emp/110

POST Method:
This HTTP request type is usually used for creating an entity i.e. a resource without an id. Once the request is successfully created, an id of the newly created entity is returned as part of the response.
POST /emp/

PUT Method:
It is similar to POST, but used to update an existing entity. We need to pass the id of existing resource along with PUT request type.
PUT /emp/123

DELETE Method:
This method can be used to removes the resource from the server. Similar to PUT you need to pass the id of the resource to be deleted.
DELETE /emp/123

TRACE Method:
Provides a means to test what a machine along the network path receives when a request is made. As such, it simply returns what was sent.

HEAD Method:
This method is same as the GET method for a resource but returns only the response headers. Similar to the GET request, HEAD Is also idempotent i.e. no side effect on Server.

It allows a client to request information about the request methods supported by a service. The relevant response header is Allow and it simply lists the supported methods.

Primarily, It can be used to establish a network connection to a resource (usually via some proxy that can be requested to forward an HTTP request as TCP and maintain the connection). Once established, the response sends a 200 status code and a “Connection Established” message.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...