Top API Interview Question 1-10
Imagine we are sitting at a table in a restaurant with a menu of choices to order from. The kitchen is the part of the “system” that will prepare your order. What is missing is a critical link to communicate your order to the kitchen and deliver your food back to your table. That’s where the waiter or API comes in. The waiter is the messenger – or API – that takes your request or order and tells the kitchen – the system – what to do. Then the waiter delivers the response back to you; in this case, it is the food.
Here is a real-life API example. We may be familiar with the process of searching for flights online. Just like the restaurant, you have a variety of options to choose from, including different cities, departure and return dates, and more. Let us imagine that you’re booking you are flight on an airline website.
We choose departure city and date, return city and date, cabin class, as well as other variables. In order to book your flight, you interact with the airline’s website to access their database and see if any seats are available on those dates and what the costs might be.
However, what if we are not using the airline’s website? What if we are using an online travel service, such as Kayak or Expedia, which aggregates information from a number of airline databases?
The travel service, in this case, interacts with the airline’s API. The API is the interface that, like your helpful waiter, can be asked by that online travel service to get information from the airline’s database to book seats, baggage options, etc. The API then takes the airline’s response to your request and delivers it right back to the online travel service, which then shows you the most updated, relevant information.
11. Automate GET method and validate the status code?
12. Automate GET method and fetch response body?
@Test(description="Verify status code for GET method-users/2 as 200")
public static void verifyStatusCodeGET() {
Response resp=given().when().get("https://reqres.in/api/users/2");
assertEquals(resp.getBody().asString(),200);
}
Click here for Answers with Scripts
13. Automate GET method and verify value from response body?(validate that total number pages =12)
14. How to pass query param with GET method in Rest Assured?
15. How to pass header for GET method in Rest Assured?
SDET Interview Question and Answers.
Jenkins Interview Questions and Answers.
Appium Interview Questions and Answers
Selenium Interview Questions and answers.
GIT Interview Questions and Answers
************************************************
✍️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
Response resp = given().header("Content-Type", "application/json").body(IOUtils.toString(file, "UTF-8")).when()
ReplyDelete.put("https://reqres.in/api/users/2");
Error observed and does not compile:
The method toString() in the type Object is not applicable for the arguments (FileInputStream, String)
Hi Sidhradh, could you please help ?
Import the correct package for IOUtils, use below:
Deleteimport org.apache.commons.io.IOUtils;
Excellent, Thank you very much.
DeleteI have added the following dependency (https://mvnrepository.com/artifact/commons-io/commons-io/2.6) in pom.xml (as I was using a maven project)
commons-io
commons-io
2.6
Error is gone.
PS: User might need to add the put.json etc in the project for the tests to pass in their machine.
Anyway, such a useful resource for learners. Thank you again.