No Code API automation – API Monkey

What are REST API Return Types?

REST services allow a wide range of answer types to give users and developers the most options. To satisfy a range of use cases, widely recognized data interchange formats, such as XML and JSON can be used to construct cross-platform and cross-application solutions. The HTML response format is the default value of the f parameter, therefore it is not essential to specify this option if HTML output is wanted.

The HTTP protocol includes a number of techniques for specifying the action to be taken on a resource. The URL identifies the resource. Depending on the server configuration, this resource could be pre-existing data or dynamically created data. Any combination of methods can be supported by the server. GET, POST, PUT, and DELETE are the most popular. HEAD, CONNECT, OPTIONS, TRACE, and PATCH are some of the other types.

Request MethodRequest has payload bodyRequest has payload bodySafeIdempotentCacheableStatus Codes
GETOptionalYesYesYesYes
Success200
Not Found404
Failure500
POSTYesYesNoNoYes
Success200 or 204
Not Found404
Failure500
PUTYesYesNoYesNo
Success200
Wrong/Format data400 or 415
Not Found404
Failure500
DELETEOptionalYesNoYesNo
Success200
Wrong/Format data400 or 415
Failure500

GET method

The GET method asks for a representation of the target resource’s state to be transferred. The GET action should only be used to retrieve data from the system and should have no other consequences.

POST method

The only method presumed to be non-idempotent is POST. Every POST method call should result in the creation of a new database object.

PUT method

Idempotent should be the PUT method. The PUT method instructs the target resource to create or update its state with the state specified in the request’s representation.

DELETE method

The DELETE method requests that the state of the target resource be removed. Sending the same DELETE request will result in the correct idempotent action because a DELETE request should accept a unique identifier to delete only one of the products from the order.

REST API Response codes

The REST API must always return an acceptable status code to the client, allowing the client to understand the problem and respond appropriately. Here are some examples of Response Codes that we could encounter while testing REST APIs with any REST API client.

1XX Codes: These are only transitory reactions that are utilized to communicate information. This status code isn’t often used. 

  • 100 Continue
  • 101 Switching Protocols
  • 102 Processing

2XX Codes: These are success numbers, which indicate that the server received and processed the client’s request successfully.

  • 200 – OK
  • 201 – Created
  • 202 – Accepted
  • 203 – Non-Authoritative Information
  • 204 – No Content
  • 205 – Reset Content
  • 206 – Partial Content
  • 207 – Multi-Status
  • 208 – Already Reported
  • 226 – IM Used

3XX Codes: In the event of URL redirection, these codes are commonly used.

  • 300 – Multiple Choices
  • 301 – Moved Permanently
  • 302 – Found
  • 303 – Check Other
  • 304 – Not Modified
  • 305 – Use Proxy
  • 306 – Switch Proxy
  • 307 – Temporary Redirect
  • 308 – Permanent Redirect

4XX Codes: If the client’s request fails, these codes are returned. It’s possible that the request is erroneous, or that the resource the client is asking for does not exist.

  • 400 – Bad Request
  • 401 – Unauthorised
  • 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 – Payload Too Large
  • 414 – URI Too Long
  • 415 – Unsupported Media Type
  • 416 – Range Not Satisfiable
  • 417 – Expectation Failed
  • 418 – I’m a teapot
  • 421 – Misdirected Request
  • 422 – Unprocessable Entity
  • 423 – Locked
  • 424 – Failed Dependency
  • 426 – Upgrade Required
  • 428 – Precondition Required
  • 429 – Too Many Requests
  • 431 – Request Header Fields Too Large
  • 451 – Unavailable For Legal Reasons

5XX Codes: When a server fails to complete a request and is unable to transmit the correct response, these codes are returned. The client does not need to alter its request in this situation because the issue is with the server where the REST API is installed.

  • 500 – Internal Server Error
  • 501 – Not Implemented
  • 502 – Bad Gateway
  • 503 – Service Unavailable
  • 504 – Gateway Timeout
  • 505 – HTTP Version Not Supported
  • 506 – Variant Also Negotiates
  • 507 – Insufficient Storage
  • 508 – Loop Detected
  • 510 – Not Extended
  • 511 –  Network Authentication Required

Leave a comment

Your email address will not be published.

One thought on “What are REST API Return Types?”