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

REST API

The document outlines the fundamentals of API automation testing, specifically using the Rest Assured library in Java, and covers manual API testing with Postman. It explains the roles of clients and servers in API interactions, the REST architectural design, and the various HTTP methods (GET, POST, PUT, DELETE) used for API requests. Additionally, it discusses the importance of parameters, headers, and the structure of endpoint URLs in API communication.

Uploaded by

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

REST API

The document outlines the fundamentals of API automation testing, specifically using the Rest Assured library in Java, and covers manual API testing with Postman. It explains the roles of clients and servers in API interactions, the REST architectural design, and the various HTTP methods (GET, POST, PUT, DELETE) used for API requests. Additionally, it discusses the importance of parameters, headers, and the structure of endpoint URLs in API communication.

Uploaded by

gayathri Jayalal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

REST API – (AUTOMATION TESTING)

API Automation with Rest Assured Library(java)


API Automation Framework Development
Manual API Testing with Postman
Core Java Basics
5 Realtime API’s – Jira, YouTube, Twitter, Google Maps, Library API
Eg: https://marriott.com/default.mi
hotels.com
Every Project has a client & a server
Client : What we see on the screen, all UI Frontend etc
Server: What it get stored from your client, all backend things like
databases/backend code that process your details & generate some
reservation number based on the destination & date provided for hotel
booking.
eg createReservation() method , iD generated /reservation is created
that id is sent to db/is stored to database
Tomorrow if u want to retrieve ur reservation details, u can use ur
database to return it back to client
API acts as an interface between your client & server,intended to
simplify the building of client-side software, to simplify design process.
Its also called a middle-tire layer b/w client & server.
We create one mariott API will call this createReservation() method
when somebody hits/try to access this API
This API we will host in the same server of marriott.com
API is independent of any language

Frontend captures all the details entered in the website for hotel
booking & send those data to the API over http protocol.
HTTP Protocol is independent of any languages.
Once API receives this request with data, it will call createReservation()
method
Create reservation requires , first in check in , checkout date, area
where they need to book,no:of rooms it needs this data to run this
method &create reservation book the room
Also data sending to API is in either JSON/XML format(both are
language independent)- These are representation of data in different
format
API again uses JSON/XML format to send response back to frontend.
Frontend will parse the JSON & extract values & add in frontend html
There’s no direct interaction b/w hotels.com & marroitt.com but
through exposing an API

REST & SOAP API’s(SOAP Webservices)


SOAP is older one(all legacy services)
SOAP has so many restrictions, tight authorization & authentication to
communicate with API’s
REST Is a light weight protocol & flexible for coding(all latest
technologies)-easy to build & maintain
Testing API is important to know how u are getting data
REST – ARCHITECTURAL DESIGN TO CREATE API’s
TERMINOLOGIES IN REST API
Endpoint/base-URI – Place where your API is hosted/lay.
Address where API is hosted on the server.
HTTP METHOS
GET/POST,PUT/DELETE
GET: To retrieve some information from server using a given-URI.
No payload/body required
Using query parameters, input data is send

POST: To send data request to server. Eg: customer information/upload


using html forms
Using form parameters & body payload, input data is send

PUT: Put replaces all current representation of the target resource with
uploaded content
Replaces existing resources already present in server
Update information

DELETE: Remove all current representation of target resources given by


a URI
CRUD OPERATIONS
Resources:- API/Collection which can be accessed from the server
Google.com/Maps
google.com/search
google.com/images
Google.com is the server where all your API’s are stored.- BASE URI
/maps, /search,/images is the resource
When a developer designs an API, he will Create a resource name to
that API & that resource name we will include in base url. So when we
are sending a request we will pass that resource name eg:
Google.com/Maps
So google knows to which API it has to direct the request
Resource & base url is mandatory

If API is expecting parameters u should also pass parameter as a part of


request.
Path Parameters: Variable parts of a URL Path. Typically used to point
to a specific resource within a collection, such as user identified by ID.
It is like a sub resource
https://google.com/images/112398
images is a collection where we are hitting endpoint
We are able to retrieve image with ID
https://amazon.com/orders/2233
orders- resourse (Theres an API that has a collection of all Orders)
Query Parameters: It is used to sort/filter/drilling (down the results)the
resources.
It is identified with ?
https://amazon.com/orders?sort_by=2/20/2022
There’s no sub resources.
Parameter name & value is provided.
Each query parameter is separated by & ampersand.
Redirect ur request to correct API

End point request url can be constructed as below:


Base URL/Resource/(query/path parameters)
Base url – server name
Resource – to point out to specific API
Optional – query/path depends on API contract

Headers/cookies: Headers represent the meta data associated with API


request & response. In layman terms, we are sending additional details
to API to process our request.
Eg: Authorization details
In header we will tell what format data is send to API whether in
JSON/XML/text/html
For that we provide content-type in header
End point: Address where API is hosted on the Server.

HTTP methods which are commonly used to communicate with Rest API’s are

GET, POST, PUT, and DELETE


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

How to send input data in GET?


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?


Ans: Using Form Parameters /Body Payload

PUT- Replaces all current representations of the target resource with the uploaded
content.

DELETE- Removes all current representations of the target resource given by a URI.

Resources:
Resources represent API/Collection which can be accessed from the Server
Google.com/maps
google.com/search
google.com/images

Path Parameters:
Path parameters are variable parts of a URL path. They are typically used to point to
a specific resource within a collection, such as a user identified by ID
https://www.google.com/Images/1123343
https://www.google.com/docs/1123343
https://amazon.com/orders/112
https://www.google.com/search?
q=newyork&oq=newyork&aqs=chrome..69i57j0l7.2501j0j7&sourceid=chrome&ie=
UTF-8
Query Parameters:
Query Parameter is used to sort/filter the resources.
Query Parameters are identified with?””

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

Headers/Cookies:
Headers represent the meta-data associated with the API request and response. In
layman terms, we were sending Additional details to API to process our request.
Example : Authorization details

End Point Request URL can be constructed as below


Base URL/resource/(Query/Path)Parameters

https://rahulshettyacademy.com/#/index

You might also like