100 To 199 Informational
100 Continue
101 Switching Protocols
102 Processing (WebDAV)
200 To 299 Success
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status (WebDAV)
208 Already Reported (WebDAV)
226 IM Used
300 To 399 Redirection
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
306 (Unused)
307 Temporary Redirect
308 Permanent Redirect (experiemental)
400 To 499 Client Error
400 Bad Request
401 Unauthorized
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 Request Entity Too Large
414 Request-URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
451 Unavailable For Legal Reasons
499 Client Closed Request (Nginx)
500 To 599 Server Error
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 (Experimental)
507 Insufficient Storage (WebDAV)
508 Loop Detected (WebDAV)
509 Bandwidth Limit Exceeded (Apache)
510 Not Extended
511 Network Authentication Required
598 Network read timeout error
599 Network connect timeout error
Authentication
Authentication is the verifiying the user to access the system.
The primary purpose of authentication is to ensure that only authorized users can gain access to the
resources. -During Authentication, user provides credentials such as a username and password,
digital certificate key. or an API then compares the provided credentials with the validate this
identity. The System Stored Credential for that user to
Authorization
-Authorization is the process of determining what actions. Operation a cerified and authenticated
user is allowed to Within the System application and resource.
-The purpose. of authorization is to control and restrict action or the operation that an authenticated
user can perform based on permission and privilege.
Rest Assured [Rest Assured 4.5.1) Maven dependency]
REST Assured is a java DSL (Digital subscriber Line) is simplifying testing Rest based Sevices build on
log & HTTP Builder. Supports post, GET, PUT and Delete request can be used verification the
response.
Local variable
These are temporary variables that will only function inside the environment they were created in.
when you change the environment will stop its access, and an error will occur.
Collection Variable
These are independent of environment and are available for all the request in a collection.
Environment Variables
These are the rest used variable scope in postman. After time single environment can be active they
environment used to execute the request.
Global variables
These are independent environment and function outside the environment, we are not required to
create an environment for global variables. Through global variable, we can access data Collection,
test scripts, requests, and environments.
Data Variable
Data variables came from external CSV and JSON file o define data sets. We can use while collections
are running through Collection Runner
"name":"{{name}}",
"job": "{{job}}"
Run Collection level: [Manual port].
Collection name ---.Run collection
Execute multiple time with different set of datas.
select files [only CSV and JSON file format will accept].
Steps to create collections?
→ collections --> create new collection
-- collection name. -- create folder -- View More action -- collection name -- Add folder-- folder name
End point
https:// rares. in /api/ users? Page = 2.
Base uri: https: // regres.in/
query Parameter: api/users Page-2
HTTP Methods
Get
Used to retrive data from server using given URI. No Need Body/ payload to pass input. Send the
input data through Query Parameter Path parameter.
Post
Send a data to sever...
Put
Replace the existing data in server.
Delete
Remove all data in server given by a uri
Path Parameter
Path Parameter is present in variables parts of resource. They are typically used to point to Specific
resources within a collection.
Path parameter are identified by /. Only path parameter is present in bare url.
Query Parameter
Query parameter is used to sort and filter the resource. Query parameter are identified by ?. Each
Query parameter separated by &.
Endpoint Request URL formation:
Base URL / Resources/(Query / path parameters)
Headers
-> Header represents meta data associated with the API request. We sending additional details to the
server to process the request.
JSON Array:
Json array represents ordered list of value. JSON array store Multiple value. It can be string, boolean,
number or object in json array. In JSON array values must be seperated by comma. The [ (square
bracket)] represents JSON array.
API
Application programning Interface (API) is an Communication Protocol between Client and sever.
HTTP request
→ Hypertext Transfer Protocol (HTTP)
→ HTTP works request and response Protocol between a client and server.
→ A Client (browser) Sends an HTTP request to the server. Send HTTP request in xml or JSON format
HTTP response
→ The client Submits HTTP request to the server, and ofter internatizing the Message the Server.
Sever sends back a response. Response contains the status Information about the request.
XML
->> Entensible Markup Language
→ XML is independent platform
JSON:
→ JavaScript object Notation. Json is platform independent language.
JSON Object
JSONObject is an unordered collection of key and Valce pains; Keys are unique strings that cannot be
null. Values can be anything from boolean, number, String.
Json object can be represented by a string enclosed within Curly braces {} with keys and Values
Seperated by a colon, and pairs separated by а сomma.
JSON Structure:
→ JSON object {}
→JSON Array []
Rest Assured Code:
public static void main(String[] args) {
//Create Place
RestAssured.baseURI="https://rahulshettyacademy.com";
String response = given().log().all().queryParam("key",
"qaclick123").header("ContentType","application/json").body(Files.payload()
).when().post("maps/api/place/add/json").then().assertThat().statusCode(200
).body("scope", equalTo("APP")).header("Server", "Apache/2.4.52
(Ubuntu)").extract().response().asString();
System.out.println(response);
JsonPath js = new JsonPath(response);
String placeId = js.getString("place_id");
System.out.println(placeId);
//Update Place
String newAddress = "Summer Walk, Africa";
given().log().all().queryParam("key", "qaclick123").header("Content-
Type","application/json").body("{\r\n"
+ "\"place_id\":\""+placeId+"\",\r\n"
+ "\"address\":\""+newAddress+"\",\r\n"
+ "\"key\":\"qaclick123\"\r\n"
+ "}\r\n"
+
"").when().put("maps/api/place/update/json").then().assertThat().log().all(
).statusCode(200).body("msg", equalTo("Address successfully updated"));
// Get Place
String getPlaceResponse = given().log().all().queryParam("key",
"qaclick123").queryParam("place_id",
placeId).when().get("maps/api/place/get/json").then().assertThat().statusCo
de(200).extract().response().asString();
JsonPath js1 = ReusableMethods.rawToJson(getPlaceResponse);
String actualAddress = js1.getString("address");
System.out.println(actualAddress);
Assert.assertEquals(actualAddress, newAddress);