21. Q: How do you verify that an API returns a success message after resource deletion?
A: Send a DELETE request to the API and check if the status code is 200 OK or 204 No Content, along with a success message like “Resource deleted successfully.”
22. Q: How can you confirm successful retrieval of a resource from an API?
A: Send a GET request and validate that the response has status code 200 OK and contains the expected data fields.
23. Q: How do you validate correct resource is returned using a resource ID?
A: Use a unique resource ID in a GET request URL and ensure the returned resource matches that ID.
24. Q: How do you test API resource retrieval using search parameters?
A: Send a GET request with specific query parameters and validate that the response matches those parameters.
25. Q: What is API pagination and how to verify it?
A: Pagination breaks large responses into pages. Verify fields like page, per_page, total, and ensure navigation is consistent.
26. Q: How do you validate sorting order in API responses?
A: Send a request with a sort parameter and check if the returned list is sorted accordingly (e.g., ascending or descending).
27. Q: How to verify API filtering functionality?
A: Apply filters in the request (e.g., /users?role=admin) and validate that only matching results are returned.
28. Q: How do you test partial string search in an API?
A: Use part of a known string in the search parameter and verify if matching results are returned.
29. Q: How do you test case-insensitive search in an API?
A: Search using uppercase/lowercase strings and ensure the response contains matching results regardless of case.
30. Q: How do you test search with special characters in an API?
A: Include special characters (e.g., @, #, %) in the search input and verify the API handles them properly without errors.
API Testing Beginner Questions and Answers
31. Q: How do you test search with multiple words?
A: Search using phrases (e.g., “test user”) and validate whether all words are matched in the response.
32. Q: How do you test alphanumeric string search in API?
A: Use strings like “user123” and confirm that the correct results containing such values are returned.
33. Q: How do you test search queries containing spaces?
A: Use properly encoded strings like “john doe” and verify if results are accurately returned.
34. Q: How do you test search with non-ASCII characters?
A: Use Unicode characters (e.g., é, ü) in the search and validate that the API returns correct localized results.
35. Q: How do you test for mixed character types in search?
A: Use a combination like User_123@ and verify the API processes it without failure.
36. Q: How do you verify search queries with HTML tags?
A: Input strings like <script>alert()</script> and ensure API escapes or ignores HTML properly to prevent XSS.
37. Q: How to test escape characters in API search?
A: Include escape characters like \n, \t, or \\ and check how the API interprets them.
38. Q: How do you validate resource representation based on content type?
A: Send requests with Accept: application/json or application/xml headers and ensure the response matches the content type.
39. Q: How do you test response compression using Accept-Encoding?
A: Send header Accept-Encoding: gzip and validate the Content-Encoding header in response is gzip.
40. Q: What happens if the request doesn’t include Accept-Encoding?
A: The response should be uncompressed (no Content-Encoding: gzip header).