Back to Blog
API Testing

Practical Guide to API Testing

Harsh Sharma QA
2 min read
Api

API testing ensures backend services function correctly and reliably. Here's a step-by-step guide to mastering API testing using Postman and Rest Assured!

🔹 Common HTTP Status Codes & Meanings

  • 200 OK – Request successful
  • 🔄 201 Created – New resource created
  • 400 Bad Request – Invalid request syntax
  • 🚫 401 Unauthorized – Authentication required
  • 404 Not Found – Resource does not exist
  • 💥 500 Internal Server Error – Unexpected server issue

🔗 Live APIs for Testing

  1. JSONPlaceholder – Fake API for testing
  2. ReqRes – User management testing
  3. HTTP Stat.us – Simulate HTTP status codes

🛠 Using Postman for API Testing

  1. Install Postman & create a new request.
  2. Select method (GET, POST, etc.) & enter the API URL.
  3. Add parameters or a request body if needed.
  4. Click "Send" and examine the response.
  5. Write assertions in the "Tests" tab:
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
  1. Automate testing using Postman's Collection Runner.

🤖 Using Rest Assured for API Automation (Java)

📌 Maven Dependency (Add this to pom.xml):

<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.4.0</version>
    <scope>test</scope>
</dependency>

📌 Basic Test Case:

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class ApiTest {
    public static void main(String[] args) {
        given()
        .when()
            .get("https://jsonplaceholder.typicode.com/posts/1")
        .then()
            .statusCode(200)
            .body("userId", equalTo(1));
    }
}

🏆 Key API Testing Concepts

  • Validate Response Codes & Body
  • Header Validation & Authentication
  • Negative Testing – Ensure the API handles invalid requests properly
  • Data-Driven Testing – Use CSV/JSON inputs for test cases

📊 Advanced API Testing Techniques

  • Mock APIs using Postman Mock Servers
  • CI/CD Integration using Newman (Postman CLI)
  • Automated Reporting with Extent Reports for Rest Assured

🚀 API testing is critical for software reliability. Whether using Postman for manual testing or Rest Assured for automation, mastering these skills helps deliver high-quality applications.

Share this article

Frequently Asked Questions

Keep Reading

More articles you might find interesting.

View All Articles
n8n
n8n

Step-by-step n8n guide to automate workflows easily....

Harsh Sharma QA
Api
Automation Testing

Compare Cypress and Selenium for modern web testing in 2025. Learn strengths, limits, use cases, and how to choose the r...

Harsh Sharma QA