Top API Interview Question 1-10
API testing has become absolutely vital with the rise of cloud applications and interconnected platforms. Many of the services we use daily rely on multiple interconnected APIs, so even if just one of them is malfunctioning, then the entire service is at risk.
Learning about APIs is not optional anymore..
In RESTful API, there are three common ways to pass data between the client and server: path parameter, query parameter, and form parameter.
****************
Path parameter
****************
Path parameters are used to identify a specific resource in the URL path. They are specified in the URL path and preceded by a colon (:). In RestAssured, we can pass path parameters using the pathParam() method.
EXAMPLE:
*********
Suppose we have a RESTful API endpoint that retrieves a user's information based on their ID, which is passed as a path parameter:
bash
GET /users/:id
CODE with Rest Assured:
************************
To pass the path parameter using RestAssured, we can use the pathParam() method like this:
int userId = 123;
given()
.pathParam("id", userId)
.when()
.get("/users/{id}")
.then()
.statusCode(200);
Click here for Answer with Scripts
22. How to pass Username and Password with form param in Rest Assured?
23. How to Setup API automation framework from scratch using Rest Assured, Gradle with code?
Click here for Answer with Code
24. How to fetch List from Response Body in Rest Assured?
Click for Job Openings and Apply
25. What are the dependencies used for Rest Assured framework in API Automation?
Click here for build.gradle file
<suite name="My suite" parallel="tests" thread-count="5">
<suite name="My suite" parallel="classes" thread-count="5">
<suite name="My suite" parallel="instances" thread-count="5">
29. How to push API Automation code to github?
*****************
Query parameter:
*****************
Query parameters are used to filter or sort data. They are specified in the URL query string and separated by an ampersand (&). In RestAssured, we can pass the query parameters using the queryParam() method.
EXAMPLE
***********
Suppose we have a RESTful API endpoint that retrieves a list of users based on their gender, which is passed as a query parameter:
bash
GET /users?gender=female
CODE with Rest Assured:
************************
To pass the query parameter using RestAssured, we can use the queryParam() method like this:
given()
.queryParam("gender", "female")
.when()
.get("/users")
.then()
.statusCode(200);
{ "name": "autouser", "job": "tester" }
REVISION:
4. What is the GET Method?
******************
Form parameter
******************
Form parameters are used to submit data to the server in an HTTP form. They are specified in the request body as key-value pairs. In RestAssured, we can pass form parameters using the formParam() method.
EXAMPLE
************
Suppose we have a RESTful API endpoint that creates a new user based on their name and email, which are passed as form parameters:
POST /users
Content-Type: application/x-www-form-urlencoded
name=Sidharth&email=sidharth@gmail.com
CODE with Rest Assured:
************************
To pass the form parameters using RestAssured, we can use the formParam() method like this:
given()
.formParam("name", "John")
.formParam("email", "sidharth@gmail.com")
.when()
.post("/users")
.then()
.statusCode(201);
TOP 15 BDD - CUCUMBER Interview Q&A
************************************************
✍️AUTHOR: LinkedIn Profile
************************************************
Learn (API-Microservice-Automation)Testing + Selenium UI Automation + SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session
Check below link for question and answers with the code:
Top API Interview Question 1-10
Top API INterview Questions 11-20
Top API AUTOMATION Interview Q&A - 21-30
*************************************************
SeleniumWebdriver Automation Testing Interview Questions:
https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver
API Testing Interview Question Set:
https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html
DevOps Interview Q&A:
https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes
Docker Interview Question Set
https://automationreinvented.blogspot.com/Docker
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign
Java Related Interview Question Set
https://automationreinvented.blogspot.com/search/label/Java
GIT Interview Question Set:
https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html
Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing
Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python
No comments:
Post a Comment