{"id":56909,"date":"2023-03-19T18:43:42","date_gmt":"2023-03-19T13:13:42","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56909"},"modified":"2023-03-22T19:12:56","modified_gmt":"2023-03-22T13:42:56","slug":"api-testing-using-postman","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/api-testing-using-postman\/","title":{"rendered":"API Testing Using POSTMAN"},"content":{"rendered":"<h2><b>What is API?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">An API is an interface or communication protocol between a client &amp; a server that intends to simplify the client-side application for a better user experience.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56906 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-1024x491.png\" alt=\"\" width=\"625\" height=\"300\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-1024x491.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-300x144.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-768x368.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-1536x736.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-2048x981.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.09-PM-624x299.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">What is a <\/span><b>RESTful<\/b><span style=\"font-weight: 400;\"> API?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">RESTful APIs follow REST architecture (<\/span><b>Re<\/b><span style=\"font-weight: 400;\">presentational <\/span><b>S<\/b><span style=\"font-weight: 400;\">tate <\/span><b>T<\/b><span style=\"font-weight: 400;\">ransfer). <\/span><\/p>\n<p><span style=\"font-weight: 400;\"># <\/span><b>What is URI for End-Point URL?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Basically, API \/ Endpoint URL is the combination of things like below: {Base URL} + {Resource} + {Path\/Query Parameter}<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56907 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-1024x264.png\" alt=\"\" width=\"625\" height=\"161\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-1024x264.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-300x77.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-768x198.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-1536x396.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-2048x528.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.18-PM-624x161.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><b>Path Parameter: <\/b><span style=\"font-weight: 400;\">Path parameters are various parts of the Endpoint URL. They are used to point to a specific resource within the collection. Let\u2019s say a user can be recognized by ID.<br \/>\nEx: https:\/\/www.google.com\/images\/234123 &lt;&#8212;&#8211; <em>Path Parameter<\/em><\/span><\/p>\n<p><b>Query Parameter: <\/b>A query<span style=\"font-weight: 400;\"> parameter is used to sort\/filter the resources. Query parameter identified by a question mark \u201c?\u201d<br \/>\n<\/span>https:\/\/www.google.com\/search?q=newyork<\/p>\n<p><b>Resources:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Resources represent API\/Collection, which can be accessed from the Server.\u00a0<\/span><\/p>\n<p>Eg:\u00a0<b>google.com\/maps<\/b><\/p>\n<p><b>google.com\/search<\/b><\/p>\n<p><b>google.com\/images\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">You can see some basic information to perform API testing. Basically, it\u2019s a client-server architecture. Client sends the request to the server and the server returns the response. You can see some information below:\u00a0<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56908 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-1024x449.png\" alt=\"\" width=\"625\" height=\"274\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-1024x449.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-300x132.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-768x337.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-1536x674.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-2048x899.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/Screenshot-2023-03-17-at-6.34.28-PM-624x274.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><b>Methods in API testing<\/b><\/h2>\n<p><b>Get Method: <\/b><span style=\"font-weight: 400;\">When we want to fetch data from the server then, we use the GET method to fetch the data.<\/span><\/p>\n<p><b>POST Method: <\/b><span style=\"font-weight: 400;\">When we want to create some new resource on the server then, we use the POST method.<\/span><\/p>\n<p><b>PUT Method: <\/b><span style=\"font-weight: 400;\">When we want to update any existing resource, then we use the PUT method to modify it. If the parameter which we want to update is available, then it modifies that parameter. If that parameter is not available, then it creates that parameter.<\/span><\/p>\n<p><b>PATCH Method: <\/b><span style=\"font-weight: 400;\">When we want to do a partial update then, we use the PATCH method to update. We pass only that parameter that we want to update, we don&#8217;t have to pass a complete payload to update the resource.\u00a0<\/span><\/p>\n<h2><b>Response Codes<\/b><\/h2>\n<p><b>1xx informational response \u2013 <\/b><span style=\"font-weight: 400;\">the request was received, continuing process<\/span><\/p>\n<p><b>2xx successful \u2013 <\/b><span style=\"font-weight: 400;\">the request was successfully received, understood, and accepted<\/span><\/p>\n<p><b>200 OK: <\/b><span style=\"font-weight: 400;\">The actual response will depend on the request method used. The response will contain an entity corresponding to the requested resource in a GET request.<\/span><\/p>\n<p><b>201 Created: <\/b><span style=\"font-weight: 400;\">The request has been fulfilled, resulting in the creation of a new resource.<\/span><\/p>\n<p><b>202 Accepted: <\/b><span style=\"font-weight: 400;\">The request has been accepted for processing but has not been completed.<\/span><\/p>\n<p><b>3xx redirection \u2013 <\/b><span style=\"font-weight: 400;\">further action needs to be taken in order to complete the request <\/span><b>4xx client error \u2013 <\/b><span style=\"font-weight: 400;\">the request contains bad syntax or cannot be fulfilled<\/span><b>.<\/b><\/p>\n<p><b>400 Bad Request: <\/b><span style=\"font-weight: 400;\">The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, size too large, invalid request message framing, or deceptive request routing).<\/span><\/p>\n<p><b>401 Unauthorized: <\/b><span style=\"font-weight: 400;\">Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.<\/span><\/p>\n<p><b>403 Forbidden: <\/b><span style=\"font-weight: 400;\">The request contained valid data and was understood by the server, but the server refuses action. This may be due to the user not having the necessary permissions for a resource.<\/span><\/p>\n<p><b>404 Not Found: <\/b><span style=\"font-weight: 400;\">The requested resource could not be found but may be available in the future.\u00a0<\/span><\/p>\n<p><b>5xx server error: T<\/b><span style=\"font-weight: 400;\">he server failed to fulfill an apparently valid request.<\/span><\/p>\n<p><b>500 Internal Server Error: <\/b><span style=\"font-weight: 400;\">A generic error message, given when an unexpected condition is encountered and no more specific message is suitable<\/span><b>.<\/b><\/p>\n<p><b>501 Not Implemented: <\/b><span style=\"font-weight: 400;\">The server either does not recognize the request method or lacks the ability to fulfill the request. Usually, this implies future availability (e.g., a new feature of a web-service API).<\/span><\/p>\n<p><b>502 Bad Gateway: <\/b><span style=\"font-weight: 400;\">The server was acting as a gateway or proxy and received an invalid response from the upstream server.<\/span><\/p>\n<p><b>503 Service Unavailable: <\/b><span style=\"font-weight: 400;\">The server cannot handle the request (because it is overloaded or down for maintenance). Generally, this is a temporary state.<\/span><\/p>\n<p><b>504 Gateway Timeout: <\/b><span style=\"font-weight: 400;\">The server was acting as a gateway or proxy and did not receive a timely response from the upstream server. <\/span><\/p>\n<h2><b>What are all validations done while performing API Testing?<\/b><\/h2>\n<p><b>Status code<\/b><span style=\"font-weight: 400;\">: &#8211; It validates whether API\u2019s returning the correct status code or not. The 201 status code should be replaced when any resource is created, 400 for bad requests, 500 for internal server error, 401 for unauthorized access, etc.<\/span><\/p>\n<p><strong>JSON<\/strong><b> Schema<\/b><span style=\"font-weight: 400;\">: &#8211; if we are working with rest assured, so as per business logic, sometimes we need to validate whether that JSON schema is correct or not.<\/span><\/p>\n<p><b>Error messages<\/b><span style=\"font-weight: 400;\">: &#8211; In case of a negative scenario, we should get appropriate error messages with an error code like 400 in case of a bad request.<\/span><\/p>\n<p><b>Response<\/b><span style=\"font-weight: 400;\">: &#8211; In the case of a happy path (positive scenarios), we validate the response that response values are expected values or not.<\/span><\/p>\n<p><b>Header<\/b><span style=\"font-weight: 400;\">: &#8211; We can also validate headers, but it depends on the requirement.<\/span><\/p>\n<p><b>Response time<\/b><span style=\"font-weight: 400;\">: &#8211; We can validate the response time of the API. Response time is the time<\/span> <span style=\"font-weight: 400;\">that is taken by the server to validate API requests and then provide responses in return. <\/span><\/p>\n<p><b>Difference between HTTP and HTTPs: <\/b><span style=\"font-weight: 400;\">HTTP stands for Hypertext Transfer Protocol,\u00a0<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"> a protocol and syntax for presenting information \u2013 used for transferring data over a network. Most information sent over the Internet, including website content and API calls, uses the HTTP protocol.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">The S in HTTPS stands for &#8220;secure.&#8221; HTTPS uses TLS (or SSL) to encrypt HTTP requests and responses, so in the example above, instead of the text, an attacker would see a bunch of seemingly random characters.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u201cIf a website uses HTTP instead of HTTPS, all requests and responses can be read by anyone who is monitoring the session. Essentially, a malicious actor can just read the text in the request or the response and know exactly what information someone is asking for, sending, or receiving.\u201d <\/span><\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>What is API? An API is an interface or communication protocol between a client &amp; a server that intends to simplify the client-side application for a better user experience. What is a RESTful API? RESTful APIs follow REST architecture (Representational State Transfer). # What is URI for End-Point URL? Basically, API \/ Endpoint URL is [&hellip;]<\/p>\n","protected":false},"author":1547,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":81},"categories":[1817,1816],"tags":[5138],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56909"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1547"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56909"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56909\/revisions"}],"predecessor-version":[{"id":56923,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56909\/revisions\/56923"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}