Back to Blog

    JsonifyTools field guide

    How to Test a REST API: Complete API Testing Guide

    Learn how to test a REST API step by step: HTTP methods, headers, query parameters, JSON bodies, status codes, response validation, and common API testing mistakes.

    By JsonifyTools7 min read
    REST API TESTING: request → response — methods, status, and JSONGET /posts/1200 OKJSON RESPONSEREST API TESTINGrequest → responsemethods, status, and JSON
    A diagram illustrating methods, status, and json.

    An API can fail before its response reaches your app: the URL may be wrong, a required header may be missing, a token may be expired, or the JSON body may not match the endpoint contract. Testing the HTTP request by itself helps isolate those details. This REST API testing guide walks through the request, the response, and the next checks to make when something does not match expectations.

    Open the free online REST API Tester

    What API testing checks

    An API test sends a defined request to a service and checks the result against an expectation. A REST endpoint is usually an HTTP URL for a resource, such as /users/42 or /orders. The method says what action is requested; headers carry metadata or credentials; query parameters refine a request; and a body carries submitted data when the endpoint accepts one.

    Manual API testing is useful while developing an integration, checking a staging release, or reproducing a bug. It does not replace automated tests, authorization checks, or monitoring. It gives you a small, visible request that you can compare with the API documentation before changing frontend code.

    1. Step 1

      Target

      Copy the endpoint URL from trusted API documentation.

    2. Step 2

      Configure

      Choose a method and add required parameters, headers, and body.

    3. Step 3

      Send

      Make the request using a test account and safe data.

    4. Step 4

      Validate

      Compare status, headers, and body with the contract.

    Choose the REST API method the endpoint expects

    GET retrieves a representation and normally has no request body. POST submits data for the server to process, often to create a resource. PUT replaces a resource representation, while PATCH applies a partial update. DELETE asks the server to remove a resource. An API may support only some methods on a route, so use its documented contract rather than guessing.

    For a first request, try the public JSONPlaceholder demo endpoint https://jsonplaceholder.typicode.com/posts/1. Select GET, send the URL, and inspect the status and JSON response. A response such as 200 OK means the server returned a successful representation; it does not prove that every field is suitable for your application.

    Build a request with query parameters, headers, and JSON

    Query parameters are part of the URL and commonly control filtering or pagination, for example ?userId=1&_limit=5. Headers are separate request metadata. An Accept header can describe a preferred response format; Content-Type: application/json tells the server how to parse a JSON request body. A JSON body belongs in the request content, not in the query string.

    POST a JSON resource with cURL
    curl -X POST https://jsonplaceholder.typicode.com/posts \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -d '{
        "title": "API testing notes",
        "body": "A small request is easier to debug.",
        "userId": 1
      }'

    In an API client, choose POST, enter the endpoint, add the two headers, and paste the JSON in the body editor. Send the request and inspect the response. This demo returns a created-resource style response, but it simulates persistence: the new post is not stored as permanent data. For a real create operation, verify saved data only in an environment you own.

    Send the GET and POST examples in API Tester

    Understand common HTTP status codes

    A status code summarizes the server’s result. Read it with the response body and headers because APIs can include useful validation details or use status codes differently within the HTTP standard.

    StatusTypical meaningWhat to inspect
    200 OKThe request succeeded with a response representation.Check the returned fields and values.
    201 CreatedA resource was created or a result was accepted as created.Look for the representation or a Location header.
    400 Bad RequestThe server could not process the request as sent.Review syntax, required fields, types, and content type.
    401 UnauthorizedValid authentication credentials are missing or were not accepted.Check the auth scheme, token, and challenge headers.
    403 ForbiddenThe server refuses the requested action.Check role, scope, and resource permissions.
    404 Not FoundThe resource is missing or the server does not disclose it.Confirm the base URL, route, and resource identifier.
    500 Internal Server ErrorThe server encountered an unexpected condition.Save a safe reproduction and check server logs.

    A 401 often points to missing or rejected credentials; a 403 often means the server understood the identity but denies that action. Implementations can deliberately return 404 to hide a protected resource. Treat the response as evidence, then compare it with the API’s documented behavior.

    Validate the API response, not just the status

    Check that the response content type is what the endpoint promises, required properties are present, values have the expected types, and arrays contain the expected records. If a response is JSON, parse it and inspect the structure. A JSON viewer helps you explore nested data; a JSON Schema validator can check a response against a structural contract. Neither check proves that a business rule, such as “this user may read this invoice,” is correct.

    Example response checks in JavaScript
    const response = await fetch(url, options);
    const contentType = response.headers.get("content-type") ?? "";
    
    if (!response.ok) {
      throw new Error(`API returned HTTP ${response.status}`);
    }
    if (!contentType.includes("application/json")) {
      throw new Error("Expected a JSON response");
    }
    
    const data = await response.json();
    if (typeof data.id !== "number") {
      throw new Error("Expected a numeric id");
    }

    For repeatable checks, turn the most important expectations into automated tests after the manual request works. Verify both positive cases and boundaries: missing fields, invalid types, expired credentials, and a user who should not see another user’s resource.

    Common API testing mistakes

    • Sending a JSON body without setting the expected content type.
    • Testing the wrong base URL, environment, method, or API version.
    • Confusing a CORS browser error with a server response or a down API.
    • Using production credentials or destructive methods against real data.
    • Assuming 200 means the response has the right shape or meaning.
    • Sharing cURL commands that contain tokens or API keys.

    A repeatable REST API testing checklist

    1. Start from the endpoint documentation and select the correct environment.
    2. Set the HTTP method, URL, query parameters, and required headers.
    3. Add authentication and a JSON or text body only when the route requires them.
    4. Send a safe request and read status, response headers, and body together.
    5. Check the response shape and repeat with authorized negative cases.
    6. Convert stable expectations into automated tests for future changes.

    For HTTP semantics and precise status definitions, see the HTTP Semantics specification (RFC 9110). The JSONPlaceholder guide documents the demo routes and notes that its create and update responses are simulated. If a response is JSON, use the JSON Viewer to inspect it, then validate its structure with the JSON Schema Validator.

    Continue your workflow

    Use these tools to build a request, inspect its data, and understand authentication responses.