Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

REST API Interview Questions and Answers

Related differences

GraphQL vs RESTful Web Services (REST API)RESTful Web Services (REST API) vs gRPC

Ques 41. What do you know about HTTP status codes?

These are the standard codes that refer to the predefined status of the task at the server. Following are the status codes formats available:

  • 1xx - represents informational responses
  • 2xx - represents successful responses
  • 3xx - represents redirects
  • 4xx - represents client errors
  • 5xx - represents server errors

Is it helpful? Add Comment View Comments
 

Ques 42. Please tell most commonly used HTTP status codes.

  • 200 - success/OK
  • 201 - CREATED - used in POST or PUT methods.
  • 304 - NOT MODIFIED - used in conditional GET requests to reduce the bandwidth use of the network. Here, the body of the response sent should be empty.
  • 400 - BAD REQUEST - This can be due to validation errors or missing input data.
  • 401- UNAUTHORIZED - This is returned when there is no valid authentication credentials sent along with the request.
  • 403 - FORBIDDEN - sent when the user does not have access (or is forbidden) to the resource.
  • 404 - NOT FOUND - Resource method is not available.
  • 500 - INTERNAL SERVER ERROR - server threw some exceptions while running the method.
  • 502 - BAD GATEWAY - Server was not able to get the response from another upstream server.

Is it helpful? Add Comment View Comments
 

Ques 43. What are the HTTP Methods?

HTTP Methods are also known as HTTP Verbs. They form a major portion of uniform interface restriction followed by the REST that specifies what action has to be followed to get the requested resource. Below are some examples of HTTP Methods:

  • GET: This is used for fetching details from the server and is basically a read-only operation.
  • POST: This method is used for the creation of new resources on the server.
  • PUT: This method is used to update the old/existing resource on the server or to replace the resource.
  • DELETE: This method is used to delete the resource on the server.
  • PATCH: This is used for modifying the resource on the server.
  • OPTIONS: This fetches the list of supported options of resources present on the server.

The POST, GET, PUT, DELETE corresponds to the create, read, update, delete operations which are most commonly called CRUD Operations.

Is it helpful? Add Comment View Comments
 

Ques 44. What are the HTTP methods and idempotent and which are non-idempotent?

GET, HEAD, OPTIONS are safe and idempotent methods whereas PUT and DELETE methods are only idempotent. POST and PATCH methods are neither safe nor idempotent.

Is it helpful? Add Comment View Comments
 

Ques 45. Can you tell what constitutes the core components of HTTP Request?

In REST, any HTTP Request has 5 main components, they are:

  • Method/Verb − This part tells what methods the request operation represents. Methods like GET, PUT, POST, DELETE, etc are some examples.
  • URI − This part is used for uniquely identifying the resources on the server.
  • HTTP Version − This part indicates what version of HTTP protocol you are using. An example can be HTTP v1.1.
  • Request Header − This part has the details of the request metadata such as client type, the content format supported, message format, cache settings, etc.
  • Request Body − This part represents the actual message content to be sent to the server.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook