REST API

REST API is an architectural style for an application program interface (API) that uses HTTP requests to access and use data. A request is sent from client to server in the form of a web URL as HTTP GET or POST or PUT or DELETE request.
GET: The HTTP GET method is used to read (or retrieve) a representation of a resource.
Example GET: Request for all Students.
HTTP GET:/api/students

POST: The POST verb is most often utilized to create new resources.
Example POST: Request for Posting/Creating/Inserting Data
HTTP POST:/api/students
{“name”:”Aditya”}

PUT: It is used for updating the capabilities. However, PUT can also be used to create a resource in the case where the resource ID is chosen by the client instead of by the server.

PATCH: It is used to modify capabilities. The PATCH request only needs to contain the changes to the resource, not the complete resource.

Example PUT or PATCH: Request for Updating Data at id=1
HTTP PUT or PATCH:/api/students/1
{“name”:”Rahul”}

DELETE: It is used to delete a resource identified by a URI.
Example DELETE: Request for Deleting Data of id=1
HTTP DELETE:/api/students/1

HTTP Status Code 
1xx informational response – the request was received, continuing process
100 Continue
101 Switching Protocols

2xx successful – the request was successfully received, understood, and accepted
200 OK
201 Created
202 Accepted
203 Non-authoritative Information
204 No Content
205 Reset Content
206 Partial Content

3xx redirection – further action needs to be taken in order to complete the request
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
306 Unused
307 Temporary Redirect

4xx client error – the request contains bad syntax or cannot be fulfilled
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-url Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed

5xx server error – the server failed to fulfil an apparently valid request
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported

Regards

Comments

Popular posts from this blog

Fortigate Basic CLI

IPv4 IPv6 Address Type