0% found this document useful (0 votes)
18 views

API Testing Brief Notes

Uploaded by

rulerofsiwan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

API Testing Brief Notes

Uploaded by

rulerofsiwan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 137

06/04/2022:

Agenda:

- What is web Service?


- Basic Concept Behind Web Service
- Why we use it?

Project Application:

- Front End(UI)
- Backend(Database)
- Service(API)

Web Service:

- Service available over the web


Scenario:

- You Speak in English and the Chef who is present inside kitchen speaks German & you
don‘t know/understand each other in that case here is a person who make sure two
applications communicate with each other & whatever response you have to get from the
server or whatever response a server has to get from a client is in a format where two
entities can understand & communicate with each other

Waiter (API)

You (Service Kitchen (Chef)(Service


Consumer) Provider)

- Waiter: Who is doing communication between you and Kitchen


- Waiter: Waiter is performing role of Web Service through an API
- We can Say he(waiter) is communicating between two applications and making sure that
the communication between two applications in Proper.

Web Service:

- Service available over web


- Enables Communication between applications over the web
- Platform independent Communication
- Using Web Service two different applications can talk to each other & exchange
data/information.
- An API is the acronym for Application Programming Interface, which is a software
intermediary that allows two applications to talk to each other.
- Each time you use an APP Like Facebook, send an instant message or check the weather
on your phone, you are using an API.

What is API?

User Layer or Business Layer(API) Database Layer


Presentation Layer

Request

Client (Service Server (Service


Consumer) Provider)

Response

Medium: HTTP

Format: XML/JSON

Two Types of Web Services:

- SOAP Service
- REST Service

08/04/2022:

Agenda: Components of Web Services (WSDL,UDDI) Types of Web


Services(SOAP)

WSDL: Web Service description Language

- WSDL Stands for Web Service description Language


- WSDL is standard format for describing a web Service.
- WSDL is pronounced as ‗Wiz-dull‘ and spelled as ‗W-S-D-L‘
- WSDL definition describes how to access a web service and what operations
it will Perform
- WSDL is often used in combination with SOAP and XML schema to
provide web services over the Internet
- A client program connecting to web service can read the WSDL to
determine what functions are available on the server.
- WSDL is an XML document with a <definitions> at the root and the child
elements,
<types>,
<message>,
<portType>,
<binding>.

<definition>:

- Element must be the root element of all WSDL documents


- It defines the name of the web service
- The definitions element is container for all the Other elements

<types>:

- WSDL <types> element take care of defining the data types that are used by
the web service
- WSDL allows the types to be defined in separate elements so that the types
are reusable with multiple web services

<message>:
- The <message > element describes the data being exchanged between the
web service providers and consumers
- Each Web Service has two Messages: Input and Output

<portType>:

- <portType> can combine one request and one response message into a
single request/response operation. This is most commonly used in SOAP
Services.
- A PortType can define multiple operations.

<binding>:
- The <binding> element provides specific details on how a portType
operation will actually be transmitted over the web.
- The bindings can be made available via multiple transports including HTTP
GET,HTTP POST or SOAP.

WSDL File/Service: <definitions>, <types>, <message>, <port Type>, <binding>

UDDI: Universal Description Discovery and Integration

- Universal description discovery integration is an XML based standard for


publishing and finding the web service.
- A web Service Providers publishes his web service (through WSDL) on an
online directory from where consumers can query & search the web services
- This is online registry/directory is called UDDI.

WSDL WSDL

UDDI

WSDL WSDL

Web Services:
- SOAP Service
- REST Service
SOAP Web Service:
- A web service that complies to a SOAP web service specifications is a SOAP Service
What are these Specifications?
- Basic Standards/Specifications: SOAP,WSDL,UDDI

Who Defines and dictates these Specifications?


- W3C(World Wide Web Consortium): An international community that develops open standards
for World Wide Web: https://www.w3c.org

09/04/2022:

Agenda: SOAP Protocol

SOAP: Simple Object Access Protocol


- SOAP is XML based protocol for exchanging information between the web services
- SOAP is a communication Protocol
- SOAP Provides data transport for Web Services.
- All the information/message exchange happens over a common format: XML
- SOAP has defined Structure/Format: SOAP Message
- SOAP Message Consists of : Envelope, Header, Body and Fault

https://www.soapui.org/downloads/soapui/

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">

<soapenv:Header/>

<soapenv:Body>

<tem:Add>

<tem:intA>?</tem:intA>

<tem:intB>?</tem:intB>

</tem:Add>

</soapenv:Body>

</soapenv:Envelope>

Envelope: (Mandatory)

- Every SOAP message has a root envelope element


- Envelope is mandatory Part of SOAP Message
- The SOAP Envelope indicates the start and the end of the message so that the receiver knows
when entire message has been received.
- The SOAP envelope solves the problem of knowing when you are done receiving a message and
are ready to Process it.

Header: (Optional)

- Contains any optional attributes of the message used in Processing the message

Body: (Mandatory)

- Contains the XML data comprising the message being sent


- The SOAP Body is a mandatory element which contains application defined XML data being
exchanged in the SOAP Message.
- The body must be contained within the envelope and must follow any headers that might be
defined for the message

Fault: (Optional)

- An optional fault element that provides information about errors that occurred while processing
the message.
- When an error occurs during processing the response to a SOAP Message is called a SOAP fault
element in the body of the message, and the fault is returned to sender of the SOAP message.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<soap:Fault>

<faultcode>soap:Client</faultcode>

<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. --->


System.InvalidOperationException: There is an error in XML document (5, 32). --->
System.FormatException: Input string was not in a correct format.

at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number,


NumberFormatInfo info, Boolean parseDecimal)

at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)

at System.Xml.XmlConvert.ToInt32(String s)

at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_Add()
at
Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationRea
der reader)

at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle,


XmlDeserializationEvents events)

--- End of inner exception stack trace ---

at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle,


XmlDeserializationEvents events)

at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)

at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()

--- End of inner exception stack trace ---

at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()

at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring>

<detail/>

</soap:Fault>

</soap:Body>

</soap:Envelope>
API Testing:
2 Types of Web Services
- SOAP Service(SOAPUI Tool)
- REST Service(Soapui and Postman)

Request

Paytm – UI/ GUI Service Travels- Travels agency/ IRCTC main Server
Parameter Provide-Service/
Values
IRCTC - Service
Response

SOAP Service :(SOAPUI Tool)


- Developer will provide WSDL file: http://www.dneonline.com/calculator.asmx?WSDL
- Unit Testing Document
- Time taken for the response=5Secs
Test Cases:
1. Validating SOAP Response=Pass

2. Validating data and count of data in the response=Pass


3. Validating Tagname/Attributes Present in the response=EC=AddResult=>Pass

4. Validating different status codes=EC-200-OK=Pass


5. Validating time taken for the response=EC=5Secs=Pass

6. Applying Assertions for Verification.


7.
7.Validating the SOAP Service by passing Test data=Re-Testing
7.1 Verify the SOAP Service by passing one digit number EC=one digits numbers should be
added=Pass

7.2 Verify the SOAP Service by passing two digit number EC=Two digits numbers should be
added=Pass
7.3 Verify the SOAP Service by passing Four/Five digit number EC=Four/Five digits
numbers should be added=Pass

7.4 Verify the SOAP Service by passing one digit number at 1st place and two digit number at 2nd
place one digit number at 1st place and two digit number at 2nd place should be added=Pass
7.5 Verify the SOAP Service by Passing zero at both placeEC =Zero number should be
added=Pass

7.6 Verify the SOAP Service by Passing both digits as –ve numbersEC=Negative numbers
should be added=Pass

8. Validating Negative Test cases


8.1 Verify the SOAP Service by passing decimal digit numbersEC=Decimal digits
numbers should not be added=Pass

8.2 Verify the SOAP Service by passing String/Fractional digit numberEC=Number should not be
added=Pass

8.3 Verify the SOAP Service by passing Null/Blank valuesEC=Should not be added=Pass
8.4 Verify the SOAP service by Passing wrong WSDL fileEC=Pass

Few Important Points:

1. How to create new SOAP Project in SOAP UI.


2. Create Test Suite and Test cases
3. Run Test cases
4. How to add Assertions(Validation Points)
- Contains
- Not Contains
- Xpath Match
- Xpath Query Match
- Valid HTTP Status Codes
- InValid HTTP Status Codes
- SOAP Fault
- NOT SOAP Fault
- Schema Compliance
- SOAP Response
- Response SLA
- Script Assertion
- JSON Path Count
- JSON Path Existance
- JSON Path Match

13/04/2022:

Agenda: Xpath Assertion,REST Service

Xpath Assertion:

- Xpath is a query language for selecting Nodes(Tagnames) from an XML document


- Xpath can also used to compute values from the content of an xml document
- To Find something is present in the response

Ex: https://ws.footballpool.dataaccess.eu/info.wso?WSDL
How to Run Test Suite in SOAP UI?

Sequential:
Parallel:
How to generate Documentation in SOAP UI?
14/04/2022:

Agenda: Status Codes, REST Service (GET Method)

GET Method:

- GET Method Service-URL/URI=https://reqres.in/api/users?page=2


- Username & Password(Basic Auth)/API Key/Bearer Token—aadjajbkdbkdb
- Time taken for the response=5 Secs
- Unit Testing Documents
Test Cases:

1. Validating REST Response=Pass


2. Validating Data and Count of Data in the REST Response=Pass

3. Validating tagnames/attributes present in the responseEC=Id, Email, first_name,


lst_name, Avatar=Pass
4. Validating different Status CodesEC=200-OK=Pass

5. Validating time taken for the responseEC=5secs=Pass


6. Applying assertion for verification
7. Validating the functionality by passing Test data(Re-Testing)
7.1 Verify by Passing Parameter as 1 in the GET MethodEC=Status Code-200-Ok &
GET Method will show response=Pass
7.2 Verify by Passing Parameter as 2 in the GET MethodEC=Status Code-200-Ok &
GET Method will show response=Pass

7.3 Verify by Passing Parameter as 3 in the GET MethodEC=Status Code-200-Ok &


GET Method will show response=Pass

7.4 Verify by Passing Parameter as 10/100/1000 in the GET MethodEC=Status Code-


200-Ok & GET Method will show response=Pass
8. Validating negative test cases!
8.1 Verify by passing decimal values in GET MethodEC=Status Code-400-Bad
Request& GET Method will not show the response=Fail-Defect

8.2 Verify by passing parameter as Null/Blank value in GET MethodEC=Status Code-


400-Bad Request& GET Method will not show the response=Fail-Defect
8.3 Verify by passing parameter as Character/String value in GET MethodEC=Status
Code-400-Bad Request& GET Method will not show the response=Fail-Defect

8.4 Verify by Passing wrong URL/URI in GET Method EC=Status Code-404- Not Found & GET
Method will not show the response=Pass

8.5 Verify by passing wrong Authorisation/bearer Token/API Key/Basic Auth(Username&


Password) in GET MethodEC=Status Code-401-UnAuthorization & GET Method will not
show the response.
8.6 Verify by changing GET Method into another methodEC=Status Code-405-Method Not
Allowed & GET Method will not show the response=Pass
15/04/2022:

Agenda: REST Terminologies,POST Method

REST Terminologies:

End Point/BaseURL: Address where API is hosted on the server

HTTP Methods which are commonly used to communicate with REST API‘s are: GET, POST,
PUT, PATCH, DELETE

GET: The GET is used to extract infromation from the given server using a given URI.While
using GET request, it should only extract data and should have no other effect on data. No
Payload/Body requred.

How to send input data in GET Method?

Ans: Using Query Parameters

POST: A post request is used to send data to the server, for example,Customer information,File
Upload,etc using HTML forms.

How to send input data in POST Method?

Ans: Using Body Payload

PUT: Replaces all current representations of the target resourse with uploaded content

DELETE: Remove the contents from the target resourse

Resourses:

Resourses represents API/Collection which can be accessed from the servers

Google.com/maps

Google.com/images

Google.com/search

Path Parameters: are variable parts of the URL Path.They are typically used to point to a
specific resourse within a collection,such as user ider identified by ID

https://www.google.com/images/1123343

https://www.google.com/docs/1123343
https://www.amazon.com/orders/112

Query Parameters:

Query Parameter is used to sort/filter the resourses

Query Parameter is identified with ―?‖

https://www.amazon.com/orders?sort_by=2/20/2022

End Point Request URL can be constructed as below:

URI=(Base URL/End Point)/Resourse/(Query/Path)Parameters

URI= URL+Resourse+Parameter Value

URL & URI-

URL – uniform resource locator


URI- uniform resource identifier
EX.
https://reqres.in/api/users?page=2
where
Base URL/Domain/Endpoint – https://reqres.in
URI- https://reqres.in/api/users?page=2
URI contains: URL & other part
contains
1. parameters/Resource/api/users
2. Parameter values/ Query Stringafter ? mark ex. page=2
URI= URL +Resource +Parameter value

POST Method/Request:
 POST Method Service-URL/URI=https://reqres.in/api/register
 Body Payload:
{
"email": "[email protected]",
"password": "pistol"
}
 Unit Testing Document
 Time Taken for the Response=5Sec
 Username & Password(Basic Auth)/API Key/Bearer Token-dalablfblf
Test Cases:
1. Validating REST Response=Pass

2. Validating Data and Count of data in the Response=Pass


3. Validating Tagname/Attributes Present in the Response=EC=>Id,Token=Pass

4. Validating Different Status Codes=>EC=Status Code-201-Created=Fail-Defect


5. Validating Time Taken for the response=5Sec=Pass

6. Applying Assertion for Verifications

7. Validating Functionality by passing Test data(Re-Testing)

7.1 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For this
email ID and Password will be inserted in the server.=Pass
7.2 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For this
email ID and Password will be inserted in the server.=Pass

7.3 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For this
email ID and Password will be inserted in the server.=Pass

7.4 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For this
email ID and Password will be inserted in the server.=Pass
7.5 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For
this email ID and Password will be inserted in the server.=Pass

7.6 Verify the POST Method/Request by Passing [email protected] with Password=>EC=For this
email ID and Password will be inserted in the server.=Pass

8. Validating Negative Test cases!


8.1 Verify POST Method/Request by passing invalid email id [email protected]=>EC=400-Bad Request=Pass

8.2 Verify the POST Method by Passing Null/Blank email id=>EC=400-Bad Request=Pass

8.3 Verify the POST Method/Request by Passing only emailID [email protected]


Without Password=>EC=400-Bad Request=Pass

8.4 Verify POST Method /Request by Passing invalid email domain [email protected] =EC=400-
Bad Request=Pass
8.5 Verify POST Method/Request by Passing valid id(id=1) with Password=EC=400-Bad Request=Pass

8.6 Verify POST Method Request/Request by Passing wrong URL/URI=>EC=404-Not Found=Pass


8.7 Verify by changing POST Method/Request into Another Method/Request=EC=405-Method Not
Allowed=Pass

PUT Method/ Request-


 PUT method Service –URL/ URI= https://reqres.in/api/users/2
 Body/ Payload-

{
"name": "morpheus",
"job": "zion resident"
}

 Username & Password/ API Key/ Barrier token - tdcgbshdnjhgfvbdhcnd


 Time take to response = 60 sec
 Unit Testing documents-

Delete method/ request-


 GET method Service –URL/ URI= https://reqres.in/api/users/2
 Username & Password/ API Key/ Barrier token - tdcgbshdnjhgfvbdhcnd
 Time take to response = 60 sec
 Unit Testing documents-
17/04/2022:

Agenda: JSON Path Count, JSON Path Existence, JSON Path Match,
Postman

GET METHOD: https://reqres.in/api/users/2

Xpath(XML document-SOAP Service) similarly JSON Path(JSON document-


REST Service)

JSON Path Count:

https://jsonpathfinder.com/
JSON Path Existence: Boolean O/P
JSON Path Match:
Postman Tool: for Testing REST Services
https://www.postman.com/downloads/##
What is Collection?

Answer: Group of requests grouped into a folder


GET Method/Request:

- GET Method Service-URL/URI=https://reqres.in/api/users?page=2


- Username& Password(Basic Auth)/API Key/Bearer Token-dbjsbfkslgfjf
- Time taken for the response=5Secs
- Unit Testing documents
Tests in POSTMAN:
- Test is putting validations in your request to make sure API is working as Expected
- Request can have many validations
- Tests are written in JavaScript in Postman
- Test can be added at Request, Collection, Folder etc
Test Cases:

1. Validate REST Response=Pass


2. Validating data and count of data present in the REST response=Pass

3. Validating tagnames/Attributes present in the responseEC=Tagname should contain


id,email,first_name,last_name,avtar=Pass
4. Validating different status codes present in the reponseEC-200-OK=Pass

5. Validating time taken for the responseEC=5Secs=Pass


6. Applying assertions for verifications
7. Validating functionality by passing Test data (Re-Testing)
7.1 Verify by Passing parameter as 1 in GET Method=>EC=Status Code-200-OK & GET Method will show
the response=Pass

7.2 Verify by Passing parameter as 2 in GET Method=>EC=Status Code-200-OK & GET Method will show
the response=Pass
7.3 Verify by Passing parameter as 3 in GET Method=>EC=Status Code-200-OK & GET Method will show
the response=Pass

7.4 Verify by Passing parameter as 10/100/1000 in GET Method=>EC=Status Code-200-OK & GET
Method will show the response=Pass
8. Validating Negative Test Cases!
8.1 Verify by Passing parameter as a decimal values in GET Method=>EC=Status Code-400-Bad Request
& GET Method will not show the response=Fail-Defect
8.2 Verify by Passing parameter as Null/Blank Values in GET Method=>EC=Status Code-400-Bad Request
& GET Method will not show the response=Fail-Defect

8.3 Verify by Passing parameter as a Character/String Values in GET Method=>EC=Status Code-400-Bad


Request & GET Method will not show the response= Fail-Defect
8.4 Verify by passing WRONG URL/URI in GET Method=> EC=Status Code-404-Not Found & GET Method
will not show the response=Pass

8.5 Verify by Passing wrong Authorization/Bearer Token/API Key in GET Method=>EC=Status Code-401-
Un-Authorization & GET Method will not show the response.
8.6 Verify by changing GET Method into another Method=>EC=Status Code-405-Method not Allowed &
GET Method will not show the response=Fail-Defect

POST Method/Request:
 POST Method Service-URL/URI=https://reqres.in/api/register
 Body/Payload-

{
"email": "[email protected]",
"password": "pistol"
}
 Username& Password(Basic Auth)/API Key/Barrier token-tcaabfj bjf lekf lklfl
 Time taken for the response=60sec
 Unit Testing Documents

Test Cases:

1. Validating the REST Response=Pass


2. Validating data and count of data in the response=Pass

3. Validating Tag names/Attributes present in response=Id, Token=Pass


4. Validating different Status Code in the responses=>EC=201-Created=Fail-Defect

5. Validating time taken for the response=>EC<5secs=Pass


6. Applying Assertions for Verification (Validation)

7. Verifying the Functionality by passing Test Data(Re-Testing)


7.1 Verify POST method/ request by passing ―[email protected]‖ with password EC=
For these email id password will be inserted in serve=Pass
7.2 Verify POST method/ request by passing ―[email protected]‖ with password EC=
For these email id password will be inserted in serve=Pass

7.3 Verify POST method/ request by passing ―[email protected]‖ with password EC=
For these email id password will be inserted in serve=Pass
7.4 Verify POST method/ request by passing ―[email protected]‖ with password EC=
For these email id password will be inserted in serve=Pass

7.5 Verify POST method/ request by passing ―[email protected]‖ with password


EC= For these email id password will be inserted in serve=Pass
7.3 Verify POST method/ request by passing ―[email protected]‖ with password EC=
For these email id password will be inserted in serve=Pass

8. Validating Negative Test Cases


8.1 Verify POST method/ request by passing invalid email id ―[email protected]‖  EC= 400-Bad
request=Pass
8.2 Verify POST method/ request by passing null/blank email id  EC= 400-Bad request=Pass

8.3 Verify POST method/ request by passing only email id ― [email protected]‖ without
password  EC= 400-Bad request=Pass
8.4 Verify POST method/ request by passing invalid email id ― [email protected]‖ 
EC= 400-Bad request=Pass

8.5 Verify POST method/ request by passing valid id (id= 1) with password EC= 400-Bad
request=Pass
8.6 Verify POST method/ request by passing wrong URL/URI  EC= 404-Not found=Pass

8.7 Verify POST method/ request by passing wrong authorization/ API Key/ barrier token
EC= 401-Un- authorization
8.8 Verify by changing POST method/ request into another method/ request  EC= 405-Not
method=Fail-Defect
Practice API: Assignment 1

Google Maps Add API (POST):

This API Will add new place into Server

Complete URL: https://rahulshettyacademy.com/maps/api/place/add/json?key=


qaclick123

Base URL/End Point: https://rahulshettyacademy.com

Resource: /maps/api/place/add/json

Query Parameters: key =qaclick123

Http Method: POST

Sample Body :
{

"location": {

"lat": -38.383494,

"lng": 33.427362

},

"accuracy": 50,

"name": "Frontline house",

"phone_number": "(+91) 983 893 3937",

"address": "29, side layout, cohen 09",

"types": [

"shoe park",

"shop"

],

"website": "http://google.com",

"language": "French-IN"
}

Sample Response:
{

"status": "OK",

"place_id": "928b51f64aed18713b0d164d9be8d67f",

"scope": "APP",

"reference": "736f3c9bec384af62a184a1936d42bb0736f3c9bec384af62a184a1936d42bb0",

"id": "736f3c9bec384af62a184a1936d42bb0"

}
Google Maps Delete API (POST):
This API Will delete existing place from Server

Complete URL:
https://rahulshettyacademy.com/maps/api/place/delete/json?key=qaclick123

Base URL: https://rahulshettyacademy.com

Resource: /maps/api/place/delete/json

Query Parameters: key

Http request : DELETE

Sample Body :
{

"place_id":"928b51f64aed18713b0d164d9be8d67f"

Sample Response
{

"status": "OK"

Google Maps get Place API (GET):


This API Will get existing place details from Server

Complete URL :
http://rahulshettyacademy.com/maps/api/place/get/json?place_id=xxxx&key=qaclick123
Base URL: https://rahulshettyacademy.com

Resource: /maps/api/place/get/json

Query Parameters: key, place_id //( place_id value comes from Add place response)

Http request: GET

Note: Key value is hardcoded and it is always qaclick123

Sample Response for the Provided Place_Id


{

"location":{

"lat" : -38.383494,

"lng" : 33.427362

},

"accuracy":50,

"name":"Frontline house",

"phone_number":"(+91) 983 893 3937",

"address" : "29, side layout, cohen 09",

"types": ["shoe park","shop"],


"website" : "http://google.com",

"language" : "French-IN"

Google Maps Put Place API (PUT):


This API Will update existing place in Server with new values

Complete URL :
http://rahulshettyacademy.com/maps/api/place/get/json?place_id=xxxx&key=qaclick123

Base URL : https://rahulshettyacademy.com


Resource: /maps/api/place/update/json
Query Parameters: key
Http Method: PUT -
Note: Key value is hardcoded and it is always qaclick123

Sample Request:
{
"place_id":"8d2573bdf6ceec0e474c5f388fa917fb",
"address":"70 Summer walk, USA",
"key":"qaclick123"

Sample Response for the Provided Place_Id


{

"location":{
"lat" : -38.383494,
"lng" : 33.427362
},
"accuracy":50,
"name":"Frontline house",
"phone_number":"(+91) 983 893 3937",
"address" : "29, side layout, cohen 09",
"types": ["shoe park","shop"],
"website" : "http://google.com",
"language" : "French-IN"

Real API:

 GET method Service –URL/ URI= api.openweathermap.org/data/2.5/weather?q={city


name}&appid={API key}
 API Key/ Barrier token - abe5bdb0a984910eb4b5a6a82a0a245d
 Time take to response = 5 sec
 Unit Testing documents-
Info Site: https://openweathermap.org/current
1. Verify the Weather API for Pune City of Maharashtra=>EC=Weather Information should return and
Status Code=200-OK= Pass

2. Verify the Weather API for Mumbai City of Maharashtra=>EC=Weather Information should return and
Status Code=200-OK= Pass
3. Verify the Weather API for Nasik City of Maharashtra=>EC=Weather Information should return and
Status Code=200-OK= Pass

4. Verify the Weather API for Delhi City of Delhi=>EC=Weather Information should return and Status
Code=200-OK= Pass
5. Verify the Weather API for Goa City of Goa=>EC=Weather Information should return and Status
Code=200-OK=Pass

6. Verify the Weather API for Deoni Village of Maharashtra=>EC=Weather Information should not return
and Status Code=404-Not Found= Pass
8. Verify the Weather API for Null/Blank city name=>EC=Weather Information should not return and
Status Code=400-Bad Request= Pass

9. Verify the Weather API by passing Country name=>EC=Weather Information should not return and
Status Code=400-Bad Request= Fail-Defect
10. Verify the Weather API by passing Invalid City/State Name=>EC=Weather Information should not
return and Status Code=404= Pass

11. Verify the Weather API by passing Invalid URL/URI=>EC=Weather Information should not return and
Status Code=404= Pass
12. Verify the Weather API by passing Invalid API Key=>EC=Weather Information should not return and
Status Code=401=Pass

Variables:(POSTMAN)
2 Types: Global Variables & Environment Variable (Local Variable)

Variables enable you to store and reuse values in your requests and scripts. By storing a value in a
variable, you can reference it throughout your collections, environments, and requests. If you need
to update the value, you only have to change it in one place.
Global variables enable you to access data between collections, requests, test scripts, and
environments. Global variables are available throughout a workspace.

Environment variables enable you to tailor your processing to different environments, for
example local development versus testing or production. Only one environment can be active at a
time.
How to Add Environments?
How to Access response from one method into another Method?

Answer: With the help of chaining API Concept (Environment Variables)

How to chain API Requests?


Get data from response of one API and refer it in Another API

Step1: Add requests in POSTMAN

Create new Collection and Add one GET Method: List Users-Gives list of users in the response

URL/URI: https://reqres.in/api/users?page=2

Save and Send

Next Add another Request-PUT Request->>Update USER

URL/URI: https://reqres.in/api/users/2

Body/Payload: Give the below details in body-> raw-Select JSON from dropdown

"name": "morpheus",
"job": "zion resident"
}
Save and Send

Step 2: Use environment variables to Parameterize values to be referred

Fetch users from request 1 and provide it in request 2

Go to new-Add Environment---APIChaining

Variable Initial Value Current Value

Username xyz xyz


Go to 2nd Method (Put) body & Give Parameter name as Username

"name": "{{Username}}",
"job": "zion resident"
}
Send request and Make Sure you are using Mentioned Environment above

Step 3: Add Script to fetch value from response from 1st API

Go to JSON Path Finder and get the JSON Path:

Go to Tests=>>>
bodyData=JSON.parse(responseBody)
value=bodyData.data[0].first_name
console.log(value)
pm.environment.set("Username1", value);

nd
Note: The value is nothing but the value which we are getting and we will be using in 2
request.
pm.environment.set("Username2", value);This statement is setting Environment Variable and
the value of this environment variable is used in second method(PUT)

Step 4: Value coming from response of 1st method will be fetched in 2nd method.

Step 5: Run the second request and Validate now go to Environment and check if the value is correct
How to Run Collection?
How to Skip any Request?
What is idempotent?
Idem potency means that multiple identical requests will have the same outcome. So it does not matter
if a request is sent once or multiple times. The following HTTP methods are idempotent: GET, HEAD,
OPTIONS, TRACE, PUT and DELETE

PUT Patch

PUT is a method of modifying resource where PATCH is a method of modifying resources


the client sends data that updates the entire where the client sends partial data that is to be
resource . updated without modifying the entire data.

HTTP PUT is said to be idempotent, So if you HTTP PATCH is basically said to be non-
send retry a request multiple times, that idempotent. So if you retry the request N
should be equivalent to a single request times, you will end up having N resources
modification with N different URIs created on the server.

It has High Bandwidth Since Only data that need to be modified if


send in the request body as a payload , It has
Low Bandwidth

Questions-

1. How much experience you have in web service testing/API?

2. What is difference between SOAP & REST service?

3. How you have tested web service/API ? Tell the Process?

4. What are different status code & meaning?

5. What are different type of method as GET, POST, PUT, PATCH, DELETE

6. What is procedure for testing web services in POSTMAN Tool.

7. What is difference between URI & URL

8. What is difference between Authorization& authentication

9. What is RestAssured?-

Ans - API service then I will use RestAssured library for doing Automation.

1. What are the Problems you facing in API Testing?

A. Understanding the functionality of API


B. Status Code is not Standard (becoz developers are putting random status codes)
C. Expected result should know as a Tester

1. What is Collection? How to run Collection?

2. In Collection if one requests you want to skip .So how will you do it?

3. What is difference between WebService& API?

4. How to Access response from one method into another Method?

5. Difference between HTTP and HTTPs?

6. What is Collection? How to run Collection?

7. What is JSON?

8. What is JSON Object?

Websites:
https://reqres.in/

https://gorest.co.in/
----------------------------------------Thank You & ALL THE BEST for Preparations----------------------------------------

You might also like