1. How do you send a POST request with a JSON object using REST Assured?
Answer:
given()
.contentType(ContentType.JSON)
.body("{\"name\":\"John\", \"age\":30}")
.when()
.post("/users")
.then()
.statusCode(201);
2. How do you extract a value from the JSON response using REST Assured?
Answer:
String userId = given()
.when()
.get("/users/1")
.then()
.statusCode(200)
.extract()
.path("id");
3. How do you send a PUT request with REST Assured?
Answer:
given()
.contentType(ContentType.JSON)
.body("{\"name\":\"Jane\"}")
.when()
.put("/users/1")
.then()
.statusCode(200);
4. How do you add query parameters in REST Assured?
Answer:
given()
.queryParam("page", 2)
.queryParam("limit", 20)
.when()
.get("/users")
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
.then()
.statusCode(200);
5. How do you validate a JSON array size in REST Assured?
Answer:
given()
.when()
.get("/users")
.then()
.statusCode(200)
.body("size()", greaterThan(0));
6. How do you send a DELETE request using REST Assured?
Answer:
given()
.when()
.delete("/users/1")
.then()
.statusCode(204);
7. How do you set headers in REST Assured requests?
Answer:
given()
.header("Authorization", "Bearer token")
.when()
.get("/profile")
.then()
.statusCode(200);
8. How do you upload a file using REST Assured?
Answer:
given()
.multiPart(new File("path/to/file.txt"))
.when()
.post("/upload")
.then()
.statusCode(200);
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
9. How do you extract the full response as a String in REST Assured?
Answer:
String responseString = given()
.when()
.get("/users/1")
.then()
.extract()
.asString();
10.How do you handle authentication with OAuth2 in REST Assured?
Answer:
given()
.auth()
.oauth2("your-access-token")
.when()
.get("/secure-data")
.then()
.statusCode(200);
11.How do you handle path parameters in REST Assured?
Answer:
given()
.pathParam("userId", 10)
.when()
.get("/users/{userId}")
.then()
.statusCode(200);s
12.How can you log request and response details in REST Assured?
Answer:
given()
.log().all()
.when()
.get("/users")
.then()
.log().body()
.statusCode(200);
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
13.How do you send a POST request with JSON body in REST Assured?
Answer:
given()
.contentType(ContentType.JSON)
.body("{\"username\":\"test\", \"password\":\"pass123\"}")
.when()
.post("/login")
.then()
.statusCode(200);
14.How can you extract values from API responses in REST Assured?
Answer:
Response response = given()
.when()
.get("/users/1")
.then()
.statusCode(200)
.extract()
.response();
String name = response.path("name");
15.How do you handle cookies in REST Assured?
Answer:
given()
.cookie("session_id", "123abc")
.when()
.get("/dashboard")
.then()
.statusCode(200);
16.What is the difference between extract().response() and
extract().path() in REST Assured?
Answer: extract().response() returns the entire response object;
extract().path() extracts a specific value from the response.
17.How do you test XML APIs with REST Assured?
Answer:
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
given()
.contentType(ContentType.XML)
.when()
.get("/xmlEndpoint")
.then()
.statusCode(200)
.body("response.status", equalTo("success"));
18.How do you validate multiple response fields in a single REST Assured test?
Answer:
given()
.when()
.get("/users/1")
.then()
.statusCode(200)
.body("name", equalTo("John"))
.body("age", equalTo(30));
19.How do you configure REST Assured to use a proxy?
Answer:
RestAssured.proxy("proxyHost", 8080);
20.Can REST Assured be used to test SOAP APIs?
Answer: Yes, by sending XML payloads with proper headers, though SoapUI is
better suited for SOAP.
21.How do you validate response status codes and body content in REST Assured?
Answer:
given()
.when()
.get("/users/1")
.then()
.statusCode(200)
.body("name", equalTo("John"));
22.How do you send query parameters and headers using REST Assured?
Answer:
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
given()
.queryParam("status", "active")
.header("Authorization", "Bearer token")
.when()
.get("/users")
.then()
.statusCode(200);
23.How do you write a basic GET request test using REST Assured?
Answer:
given()
.when()
.get("/users")
.then()
.statusCode(200);
24.How do you set up REST Assured in a Java project?
Answer: Add dependencies in Maven/Gradle and import relevant classes in code.
25.What is REST Assured, and why is it popular for API testing?
Answer: A Java library with fluent syntax for automated REST API testing and
validation.
26.How do you automate API tests using Postman?
Answer: Write JavaScript tests in Postman and run collections using Newman CLI.
27.How do you create and manage environments in Postman?
Answer: Define environment variables for different setups and switch between them
easily.
28.What is Newman and how does it relate to Postman?
Answer: A command-line runner to execute Postman collections for automation.
29.How do you write pre-request and test scripts in Postman?
Answer: Use JavaScript in Postman’s scripting tabs to set up requests and validate
responses.
30.How do you handle dynamic data and data-driven testing in Postman?
Answer: Use variables and external data files (CSV/JSON) for running tests with
varying inputs.
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
31.How do you chain API requests in Postman and REST Assured?
Answer: Capture response values and pass as variables to subsequent requests.
32.How do you test error handling in APIs?
Answer: Send invalid requests and verify proper status codes and error messages.
33.How do you test APIs involving database interactions?
Answer: Validate API responses against database records and clean up test data.
34.How do you test API performance?
Answer: Use tools like JMeter or Postman with large data sets and monitor response
times.
35.What is the difference between PUT and PATCH methods?
Answer: PUT replaces entire resource; PATCH updates parts of a resource.
36.How do you validate JSON schema in Postman and REST Assured?
Answer: Use JSON schema validator libraries or built-in validators.
37.How do you handle authentication in API testing?
Answer: Use Basic Auth, Bearer tokens, OAuth 2.0 as per API requirements.
38.How do you handle rate limiting in API testing?
Answer: Monitor headers, add delays, or retries to respect limits.
39.How do you mock APIs in Postman?
Answer: Use Postman mock server feature to simulate endpoints.
40.What are best practices for organizing test suites in Postman and REST Assured?
Answer: Group tests logically, modularize code, and reuse common components.
41.How do you handle asynchronous API calls in tests?
Answer: Poll or wait for completion before assertions.
42.How do you log request and response in REST Assured?
Answer: Use .log().all() or .log().body() for detailed logs.
43.How do you test security aspects in API testing?
Answer: Check authentication, authorization, injection attacks, and data validation.
44.How do you upload files in REST Assured?
Answer: Use .multiPart() method with the file object.
45.How do you download and verify files via API?
Answer: Extract response bytes and verify content or checksum.
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/
46.How do you extract cookies from API responses?
Answer: Use response.getCookie("cookieName").
47.How do you run REST Assured tests in CI/CD pipelines?
Answer: Integrate test execution via Maven/Gradle commands in pipelines.
48.How do you test APIs without UI?
Answer: Use Postman, REST Assured, or cURL to directly interact with endpoints.
49.How do you test REST vs SOAP APIs?
Answer: REST uses HTTP verbs with JSON/XML; SOAP uses XML with strict
standards.
50.How do you maintain test data for API testing?
Answer: Use setup and teardown scripts, mocks, or isolated test environments.
https://www.linkedin.com/in/rabiya-sulthana-k-18b9151b5/