Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 2.2 KB

Learning REST API's.md

File metadata and controls

69 lines (45 loc) · 2.2 KB

REST API:

Representational State Transfer refers to a group of software architecture design constraints that bring about efficient, reliable, and scalable systems.

REST Methods

  • Get
  • Post
  • Put
  • Patch
  • Delete
  • Options
  • Head

Get requests may contain the following

  • Host
  • Content Type
  • Authorization
  • Cache Control

Example of GET request in JSON format

Response usually contains

  • Required : True/false
  • Description
  • Type

DELETE request, _If force=true is given in the URL, then post will be completely deleted. If just delete request is passed, then it will be sitting in the trash bin. Content type should match in GET and POST request Same URI for GET and POST

  • POST: Create new resource.

Example of Post request

Success and Failure

Code Sample for Post request

  • PUT: Contains ID and content.(Updating an existing resource and may allow it to create a new resource.)

Example of Put request

Code sample for Put request

  • PATCH: Modify the existing resource using ID.

Example of Modify request

  • DELETE: Deleting data based on ID

Example of Delete request

  • OPTIONS: Creates description of the resource.

  • HEAD: retrieves the head section of the response.

STATUS CODES:

  • 1XX - Information
  • 2XX - Success
  • 3XX - Redirection
  • 4XX - Client Error
  • 5XX - Server Error