HTTP Status codes while accessing API - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Friday, 30 March 2018

HTTP Status codes while accessing API


2xx Success
200 OK GET
The request has succeeded.
201: POST: which means CREATED. Meaning *The request has been fulfilled and resulted in a new resource being created. 204: No Content:POST  The server has fulfilled the request but does not need to return an entity-body

3xx Redirection
302 errors in the HTTP cycle 302 is moved temporarily
Any client (e.g. your Web browser or our CheckUpDown robot) goes through the following cycle when it communicates with the Web server:
Obtain an IP address from the IP name of the site (the site URL without the leading 'http://'). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
Open an IP socket connection to that IP address.
Write an HTTP data stream through that socket.
Receive an HTTP data stream back from the Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.
This error occurs in the final step above when the client receives an HTTP status code that it recognises as '302'.
The 302 response from the Web server should always include an alternative URL to which redirection should occur. If it does, a Web browser will immediately retry the alternative URL.

304 -Not Modified- Status Code Explained (Simply means that document u r  requesting is already cached and nuthing new is there or nothing has been modified)
The 304 status code is sent in response to a request (for a document).
Normally, when a document is cached, the date it was cached is stored. The next time the document is viewed, the client asks the server if the document has changed. If not, the client just reloads the document from the cache.
4xx: Client Error - This category of error status codes points the finger at clients.
415 Unsupported Media Type
The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
For example there is no GET Method supported by API and you try to hit it with GET Method it might give you 415

In Get there is no Payload

401 Unauthorized
The request requires user authentication.
It must be used when there is a problem with the client’s credentials
A 401 error response indicates that the client tried to operate on a protected resource without providing the proper authorization. It may have provided the wrong credentials or none at all.
If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials.

Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided.

402 Payment Required
This code is reserved for future use.

 403 Forbidden
403 (Forbidden) should be used to forbid access regardless of authorization state
A 403 error response indicates that the client’s request is formed correctly, but the REST API refuses to honor it. A 403 response is not a case of insufficient client credentials; that would be 401 (“Unauthorized”).REST APIs use 403 to enforce application-level permissions.

For example, a client may be authorized to interact with some, but not all of a REST API’s resources. If the client attempts a resource interaction that is outside of its permitted scope, the REST API should respond with 403.

405 Method Not Allowed
 400 Bad Request
The request could not be understood by the server due to malformed syntax. 
404 (Not Found) must be used when a client’s URI cannot be mapped to a resource

HTTP 423 status code

The 423 (Locked) status code means the source or destination resource of a method is locked. This response SHOULD contain an appropriate precondition or postcondition code, such as 'lock-token-submitted' 

It means user is locked example in Ecommerce site, if you want to lock user , if he has done fraud

5xx Server Error
503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.



No comments:

Post a Comment