0% found this document useful (0 votes)
7 views47 pages

API Testing

The document provides a comprehensive guide on API testing, detailing various types of requests (GET, POST, PUT) and how to create a simple REST API using Node.js and JSON-server. It includes step-by-step instructions for creating a 'Students.json' file, retrieving student data, and performing CRUD operations. Additionally, it covers validation techniques for response headers, cookies, and response body data types.

Uploaded by

pri.sharma9870
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views47 pages

API Testing

The document provides a comprehensive guide on API testing, detailing various types of requests (GET, POST, PUT) and how to create a simple REST API using Node.js and JSON-server. It includes step-by-step instructions for creating a 'Students.json' file, retrieving student data, and performing CRUD operations. Additionally, it covers validation techniques for response headers, cookies, and response body data types.

Uploaded by

pri.sharma9870
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

API Testing

Get Request: Sending a request to get some data from the server is called get request.
Post Request: Sending a request to store some data into the database/server is called post
request.
Put Request: Sending a request to update the existing data in the server.
Note: To create your own API these two software must be installed.

til
Pa
g
Install: 1. Nodejs software with npm
ra
Check the software is available or not from the cmd : Nodejs: node –version and npm: npm –
version
Pa

Install : 2. Json-server.

Create an Own/Dummy REST API “ Students.Json “ file with the following data :
Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

{
"students":[
{
"id": 1,
"name": "John Doe",
"age": 18,
"grade": "12th",
"subjects": [
"Math",
"Physics"
,

til
"English"
]
},
{

Pa
"id": 2,
"name": "Jane Smith",
"age": 17,
"grade": "11th",
"subjects": [
"Biology",
"Chemistry",
"History"
g
]
},
{
ra
"id": 3,
"name": "David Johnson",
"age": 16,
"grade": "10th",
"subjects": [
Pa

"Computer Science",
"Spanish",
"Art"
]
}
]
}

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

How to create own API ?​ Task no-1


Ans: Goto the location where the “ Students.json “ File is stored.

Step-1

til
Pa
Step-2
g
ra

Step-3
Pa

Link: http://localhost:3000/students

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

How to get single student data from the above URL?​ Task No- 2

til
How to get all students data from the above URL?​ Task No- 3

Pa
g
ra
Pa

How to create new student data?​ Create = Post​ Task No- 4

Ans: Add a new collection “ Post “ then give the url. Then insert a new request in the “Request Payload “

Step-1 (Request Payload)

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Step-2 (Response Payload)

Pa
g
ra
Pa

How to update the earlier “New student data” data?​ Update = Put Task No- 5

Ans : Make sure to set the “Id Number” beside the link (http://localhost:3000/students/2f05)

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
How to delete any data from the request ?​

Ans : I want to delete ID = “ 2f05 “


Pa
Task No- 6
g
ra
Pa

Validation :
1.​ Response Body

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

2.​ Headers
3.​ Cookies
4.​ Status Code
5.​ Time

JSON ---Javascript object Notation

til
Pa
g
ra
Pa

Note: In JSON format, we have to represent the data in the form of KEY: Value Pair

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
String

Pa
Example

"name": "John",

Note: KEY is always included in “ “ double quotation


g
ra

Here { “name” : “ John “ }------name is included in double quotation But John included in double
quotation here because John is string.

When we input multiple inputs in one variable then we use [ ] this is called JSON Array.
Pa

Example:

"name": "John",

"age": 30,

"phone": [12345,6789]

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
Example :
{
"Firstname": "John",
"Lastname": Null,
"age": 30,
"phone": [12345,6789],
"Status": true
}
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

JSON Object object—Which Contains Multiple KEY : Value Pairs


Student Data ( Student Contains SID, SName, Grade ) HERE 4 Student/Object.

"Student":[

{
"SID":101,
"SName":"Kamran Tusher",
"Grade":A
},

til
{
"SID":102,
"SName":"Lamisha Rahman",
"Grade":A+

Pa
},

{
"SID":103,
"SName":"Zenith Chowdhury",
"Grade":A
},
g
{
"SID":104,
"SName":"Liyana Lio",
"Grade":A
ra

}
]
}
Pa

Explanation

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Validate JSON Path :​ Task No- 7

til
Ans: I want to extract the red-marked data from the file.
Extract Procedure— JSON Path : Student[1].SName​
Pa
How to extract any data from the above JSON file by using JSON path ?

Lamisha Rahman
g
Note: For complex JSON file we need to use tools to extract the data
Tools:​ 1)JSON Pathfinder.​ 2) JSON .com
ra
Example: I want get the 2nd object’s first name data JSON path​ Site Link : Link
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

JSON path Validation​ ( For path validation Site link: Link )

til
1. Status Code:
Response Validation Pa
g
Step-1
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Step-2

For Single Status code

pm.test("Response status code is 200", function () {

pm.response.to.have.status(200);

});

til
Pa
g
For Multiple Status code

pm.test("Successful Post request", ()=> {

pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);


ra

});
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

1.​ Headers Validation​ Task No—9

We will Validate “Key” of the header “ given below

til
Pa
How to validate All the “KEY” response header is present :
pm.test("Content-Type is present", function () {
g
pm.response.to.have.header("Content-Type");

});
ra

pm.test("Content-Length is present", function () {

pm.response.to.have.header("Content-Length");

});
Pa

pm.test("X-Powered-By is present", function () {

pm.response.to.have.header("X-Powered-By");

});

pm.test("Access-Control-Allow-Origin is present", function () {

pm.response.to.have.header("Access-Control-Allow-Origin");

});

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

pm.test("Access-Control-Allow-Methods is present", function () {

pm.response.to.have.header("Access-Control-Allow-Methods");

});

pm.test("Access-Control-Allow-Headers is present", function () {

pm.response.to.have.header("Access-Control-Allow-Headerss");

});

pm.test("Date is present", function () {

pm.response.to.have.header("Date");

til
});

pm.test("Connection is present", function () {

pm.response.to.have.header("Connection");

Pa
});

pm.test("Keep-Alive is present", function () {

pm.response.to.have.header("Keep-Alive");

});

Here Is the result Images:


g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

How to Validate the “ value “ of the header ?​ Task No-10

til
Code is given below

pm.test("Content-Type is application/json", () => {

});
Pa
pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

All the “ Value “ validated together using an Array

const headers = [

{ key: "X-Powered-By", value: "tinyhttp" },

{ key: "Access-Control-Allow-Origin", value: "*" },

{ key: "Access-Control-Allow-Methods", value: "GET, HEAD, PUT, PATCH, POST, DELETE" },

{ key: "Access-Control-Allow-Headers", value: "content-type" },

{ key: "Content-Type", value: "application/json" },

//{ key: "Date", value: "Tue, 10 Dec 2024 20:04:59 GMT" },

til
{ key: "Connection", value: "keep-alive" },

{ key: "Keep-Alive", value: "timeout=5" },

{ key: "Content-Length", value: "131" }

Pa
];

// Loop through headers and validate each using a basic for loop

for (let i = 0; i < headers.length; i++) {

const header = headers[i];

pm.test(`${header.key} is ${header.value}`, () => {

pm.expect(pm.response.headers.get(header.key)).to.eql(header.value);
g
});

}
ra

2.​ Cookies Validation :


We need to verify the cookie name and the value
How to check the cookies are present in the response?
Pa

Ans:
3.​ Response Time validation :
How to check the response time ?
Ans: pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Actually, the response time keep changing during the execution.

til
Pa
g
ra

Response Body:​ Task No-


Pa

Different types of validation are done in Response Body validation:


1.​ Validate the Data type of the Data in the fields
2.​ Validate the Array Properties/Array Content in the fields
3.​ Validate the Data of the fields are matched/Correct or Not
4.​ Validate the Json schema

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

1.​ Validate the Data type of the Data in the fields :

Validate the “Type” of the value: Validate all the “data type” of these data from every
assertion in this Response body.
How to validate the ‘Data type ‘ of the value from these assertions in the response body?
Here is the response body: (For single object in the response body)
{

"id": "1",​ ​ //verify the data type of id


"name": "John Doe", //verify the data type of name

til
"age": 18,​ //verify the data type of id
"grade": "12th",​ ​//verify the data type of id

Pa
"subjects": [​ //verify the data type of subject
"Math",
"Physics",
"English"
]

}
g
CODE:
ra

const jsonData = pm.response.json();


pm.test("Test the data type of the response",() =>{
pm.expect(jsonData).to.be.an("object");
Pa

pm.expect(jsonData.name).to.be.an("String");
pm.expect(jsonData.id).to.be.an("String");
pm.expect(jsonData.age).to.be.an("number");
pm.expect(jsonData.subjects).to.be.an("Array");

});

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

(For multiple object in the response body):;


CODE:
const jsonData = pm.response.json();
pm.test("Test the data type of the response", () => {
pm.expect(jsonData).to.be.an("array");
});

jsonData.forEach((item) => {

til
pm.test(`Test the data for item with id: ${item.id}`, () => {
pm.expect(item).to.be.an("object"); // Ensure each item is an object
pm.expect(item.name).to.be.a("string"); // Validate 'name' is a string

Pa
pm.expect(item.id).to.be.a("string"); // Validate 'id' is a string
pm.expect(item.age).to.be.a("number"); // Validate 'age' is a number

pm.expect(item.subjects).to.be.an("array"); // Validate 'subjects' is an array


});
});
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

2.​ Validate the Array Properties/Array Content in the fields:

Array properties in the response body :


How to validate the Array properties in the response body ?
-(Validate a single property in the Array from the response body)
CODE:
const jsonData = pm.response.json();
pm.test("Test the data type of the response",() =>{
pm.expect(jsonData.subjects).to.include("Math");

til
});

Input:

Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
-(Validate a Multiple property in the Array from the response body)
CODE:

Pa
const jsonData = pm.response.json();
pm.test("Varify the multiple property in the Array ",() =>{
pm.expect(jsonData.subjects).to.have.members(["Math","Physics","English"]);
});
Input:
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
3.​ Validate the Data of the fields are matched/Correct or Not :

Pa
Validate the “value “ Of the response body
How to validate the value of of every field/assertion is match or not from the response body?
Ans:
CODE:

const jsonData = pm.response.json();


g
pm.test("Test the data type of the response",() =>{
//pm.expect(jsonData).to.be.an("object");
ra
pm.expect(jsonData.name).to.eql("John Doe");
pm.expect(jsonData.id).to.eql("1");
pm.expect(jsonData.age).to.eql(18);
pm.expect(jsonData.subjects[0]).to.eql("Math");
Pa

pm.expect(jsonData.subjects[1]).to.eql("Physics");
pm.expect(jsonData.subjects[2]).to.eql("English");
});

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
g
ra
Pa

4.​ Validate the Json schema :

Validate the Json Schema :

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Convert Json to JSON schema link : Link

til
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Schema validation code: //Validate Json Schema of the response body.

pm.test("Status code is 200", function () {

pm.expect(tv4.validate(jsonData,schema)).to.be.true;

});

PostMan variables
What is a variable?

til
Ans: Variable is something which contains some data.
Why is variable need in postman?
Ans: Variable Is used to avoid the duplicate value
Where is use variable in Postman?

Scope?
Ans : where we can create the variables
Scope to set up the variables:
Pa
Ans : Variable is used in multiple level like Collection, and Environment. Request level.
g
1.​Global variable ---Set the variable in global level
2.​Collection variable​ Set the variable in collection level
ra

3.​Request variable​ Set the variable in request level


4.​Environment variable​ Set the variable in environment level
5.​Data variable​ Set the variable in data level.
Pa

1.​ Global variable:


How do we create a global variable?

Ans:​ workspace-- Collection​ Request/Folder.

A global variable is accessible throughout the every workspace.

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Step-1
Create a Global variable on the collection and save.
Step-2

til
Step-3​ (Get Request)
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Step-5 ----(Post Request) Pa
Put this “ {{url_global}} ” variable in every collection accordingly to change the value
g
ra
Pa

Step-6​ (Put Request)

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Step-7 ​ (Delete Request) Pa
g
ra
Pa

Step-8

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
s

Step-9
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Collection variable : Collection variable is accessible within the Collection among multiple
requests.
Step-1

til
Step-2
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Environment Variable:​ Accessible in all collections but we use it for a specific environment

til
Pa
Run the whole collection of Environment Variable:
Step-1
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Step-2

til
Console result
Pa
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Local Variables: Accessible only within the request.

til
Pa
Chaining of API : The response of one API becomes the request of another API is called Chaing
of API.
g
Task:
When I pass a body it will create an ‘ID’ in response to request from the body..Then this ‘ ID ‘
ra

will stored in a variable.

Step-1) Pass this body


Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
Step-2
Write a test script in the “ post-response “ body.
Script
var JsonData= JSON.parse(ResponseBody);
pm.environment("id"."JsonData.id");
g
Here this particular script will set an environment and give a id for the particular body which is
given on the top.
Another Sample API from internet:
ra

Step -1 : Take an API from the website : (https://gorest.co.in/#google_vignette ).Here we will


find some sample API .
Step-2 : To access this API We need to generate a token and pass it as part of the Authorization.
Pa

Note: Most of the time , whatever API is accessing through internet, those API would have some
authorization
How to get Access token?
Sign up for Github/Google and click on anyone then get the access.
Sample API:
URL: https://gorest.co.in/
End Point

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

POST​ ​/public/v2/users​ Create a new user


GET​ /public/v2/users/7386739​ Get user details
PUT|PATCH​ /public/v2/users/7386739​ Update user details
DELETE​ /public/v2/users/7386739​ ​ Delete user
Created Token: cf842adb5472f7db0196c587b55a74dfccd50e82e0f361ab59326843207adddf
Response Body
{
"name":"Chowdhury Kamran Hossain",

til
"gender":"male",
"email":"ckh123@gmail.com",

Pa
"status":"active"
}
Note: This Response Body is required for Post and Put requests only.
Note : Then Use the token in the Authorization section in the Collection level to cover all the
request
GorestApi_Chaining example :
g
Process:
Step-1: Create a Collection called “GoRestAPI_Chaining
ra
Step-2: Create Post , Get, Put and Delete Request along with the given Url
Step-3: Set the Token in the collection Level for authorization
Step-4 : Then Execute all the request
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Step-1: First of all execute a “ Post Request “ create a record.

til
Pa
After getting the result I have updated some informations aginst the ID which is generated.
g
ra
Pa

The request will not be executed further with the same records. Below you can see the result
Image:

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

til
Pa
g
ra

That is why we need to change the information of the record simultaneously.But it is difficult
to change the data manually in everytime, that is why we need to make it as automated.
Pa

How to change the data in the records automatically every time?


Ans: Before sending the ‘Post Request’ we need to write some script to change the date in the
record automatically.
We will write the Script in the ‘Pre-request ‘ section.
Here will change the Name and Email automatically

Here is the process ;

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Firstly , Write the script in the pre-request section with this


code:
var random=Math.random().toString(36).substring(2);

var username="Chowdhury"+random;
var useremail="chowdhury"+random+"@gmail.com";
Input:

til
Pa
g
ra

Secondly, same script should write in the body of the post request
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Same script is written in the body of the post request here is that code
Code:
{
"name":"{{name_env}}",
"gender":"male",
"email":"{{email_env}}",
"status":"active"

til
Output:

Pa
g
ra
Pa

After execute the post request then an ID will generate . This ID will need for other request .so,
we need to extract this ID from the response .
So write this script in the Post- Request section.
Code:

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

var json.Data= JSON.parse(responseBody );


pm.environment.set("userid_env",jsonData.id);

Parameterisation | Data Driven Testing:


How can we use data parameter/Data variable?
Process: We can specify the variables and value in the external files like CSV file.CSV or Json file.
BooksApi: Two things are going to describe I) Books (Do not need token)II) Order . For order
request, (we need to use a token for authentication.)

til
URL: http://simple-books-api.glitch.me/
BooksAPI: Endpoint
Types of request:

Pa
Status: Check the books are available or not .
GET /Status
List of Books:
GET /books
Get a single Book:
g
GET /books/ :bookid
Task: Now we are going to perform Data Driven testing on this Particular API.
ra

Step-1: First, we need to execute a Post request to generate a Toke for Authentication through
the given link and body.
Link/Url: http://simple-books-api.glitch.me/api-clients/
Body:
Pa

Generated Token:
Step-2 : Perform Get request using
this Url :
http://simple-books-api.glitch.me And
End Point: /Status
Get Request : http://simple-books-api.glitch.me/Status

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Image:

til
Pa
Step -3 : Perform get request usng the given url for getting BookList from the BookAPI.
URL: http://simple-books-api.glitch.me/books
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Step -4: Perform get request for getting single book/specific book from the BookAPI.
Url: http://simple-books-api.glitch.me/books/1

til
Swagger:
Petstore: It’s a free API .
Pa
g
Petstore support two types of response json and xml
Here will see how to validate JSON and xml response. for this, we need to access a API called
ra
Petstore.
How to access the Petstore documentations?
Url of the Petsore documentation: https://petstore.swagger.io/
User model provides the responses in the Json format.Different API request in User model
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Now click on Post request, which is in the given screenshot. Then this page will appear

Now click on the Try it out to insert the data in the body.

til
Pa
After inserting the data the click on execute and get the output which is in below
g
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02


​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

Now I will import this API in the PostMan softwarez:


First copy the curl:
curl -X 'POST' \
'https://petstore.swagger.io/v2/user' \
-H 'accept: application/xml' \
-H 'Content-Type: application/json' \
-d '{
"id": 18,

til
"username": "Kamra Hossain Chowdhury",
"firstName": "Kamran Hossain",

Pa
"lastName": "Chowdhury",
"email": "khc123@gmail.com",
"password": "string",
"phone": "01738824389",

"userStatus": 0
}'
g
Then Create a collection in the postman and import the curl
ra
Pa

Parag Patil | paragpatil.rcpit@gmail.com | 7666170317 | https://topmate.io/parag_patil02

You might also like