![]() |
VOOZH | about |
API testing ensures that an Application Programming Interface (API) works as expected. Tools like Postman allow developers to send HTTP requests (GET, POST, PUT, DELETE, etc.), validate responses and automate test cases. This helps assess the functionality, reliability, performance and security of an API.
Postman is a widely used API testing and development tool that helps developers send HTTP requests, validate responses, and automate API testing through a simple interface.
Prerequisites:Download Postman.
<Request Method> <Request URL>
Example:
GET https://api.example.com/users
Letβs assume we have a Library API with the base URL:
https://library-api.postmanlabs.com
https://library-api.postmanlabs.com/books
{
"title": "To Kill a Mockingbird New" ,
"author": "Harper Lee",
"genre": "Fiction",
"yearPublished": 1960
}
And then check the response in the "Response" window. You should be able to view book details. Now for API testing, first, go to the "Tests" tab.
Look for the code bracket icon. Select JavaScript Fetch. Write JavaScript code for fetch response is, like:
const id = pm.response.json().id
pm.collectionVariables.set("id", id)
This script extracts the id from the response and stores it as a collection variable for future requests.
Output: Since the API Testing was successful. It shows the response status and body.
| Status Code | Type | Meaning |
|---|---|---|
| 200 | Success | OK |
| 201 | Success | Resource Created |
| 204 | Success | No Content |
| 400 | Client Error | Bad Request |
| 401 | Client Error | Unauthorized |
| 403 | Client Error | Forbidden |
| 404 | Client Error | Not Found |
| 500 | Server Error | Internal Server Error |