Back to Blog
Lesson 34 of the REST API Design: Design Your First Clean REST API course
API ArchitectureAugust 21, 20264 min read

Testing API Endpoints: Manual Validation with cURL and Postman

Learn how to manually test your API endpoints using cURL and Postman. Validate HTTP responses, status codes, and JSON payloads to ensure your API works as designed.

API TestingPostmancURLREST APIValidation
A simple white paper checklist with one red checkmark, ideal for concepts like completion or approval.

Previously in this course, we focused on generating interactive documentation with Swagger UI. While documentation helps others understand your API, you need a reliable way to verify that your code actually behaves as described. In this lesson, we shift from documentation to manual verification.

Testing your API manually is the fastest way to catch "off-by-one" errors in your routing, unexpected status codes, or malformed JSON payloads. We will use two industry-standard tools: cURL for command-line speed and Postman for visual request management.

Why Manual Validation Matters

Before you write automated test suites, you must possess the ability to perform ad-hoc validation. When you deploy a new endpoint or tweak your standardized response envelopes, you need immediate feedback.

Manual testing allows you to:

  1. Verify HTTP Semantics: Check if your GET and POST semantics are correctly implemented.
  2. Inspect Headers: Ensure that content types (application/json) and version headers are present.
  3. Debug Edge Cases: Manually trigger specific scenarios, like sending an empty body or an invalid ID, to see how your server handles errors.

Testing with cURL

Red and yellow cars shown in a head-on collision during a crash test for safety evaluation.

cURL is the universal language of APIs. It comes pre-installed on most Unix-based systems and is perfect for quick sanity checks.

To test your GET /v1/tasks endpoint, open your terminal and run:

Bash
curl -i -X GET http://localhost:3000/v1/tasks

The -i flag is crucial here; it tells cURL to include the HTTP response headers in the output. The -X flag specifies the request method. You should see a response like this:

HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "data": [...],
  "meta": { "total": 10 }
}

If you need to test a POST request with a payload, use the -d (data) flag:

Bash
curl -i -X POST http://localhost:3000/v1/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "Learn API Testing", "status": "pending"}'

Visual Validation with Postman

While cURL is excellent for quick tasks, Testing with Postman: A Guide for API Quality Assurance is far superior for complex workflows. Postman provides a GUI to save requests, manage environment variables, and view structured JSON responses.

Steps to Validate an Endpoint:

  1. Create a Collection: Group your Task Manager requests by version (e.g., "Task API v1").
  2. Define the Request: Set the method to POST and the URL to http://localhost:3000/v1/tasks.
  3. Set the Body: Select the "raw" body type and choose "JSON". Paste your payload there.
  4. Send and Assert: After clicking "Send", look at the "Tests" tab. You can write simple JavaScript assertions here, such as:
JAVASCRIPT
pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
});

pm.test("Response has data field", function () {
    pm.response.to.have.jsonBody("data");
});

Hands-on Exercise

  1. Open your Task Manager project and ensure your server is running.
  2. Using cURL, retrieve your tasks and verify the response header Content-Type is application/json.
  3. Using Postman, create a new POST request to create a task. Verify that your API returns a 201 Created status code and the correct JSON response structure.
  4. Attempt to send a request with a missing required field (e.g., missing title) and verify that your API returns a 400 Bad Request.

Common Pitfalls

  • Ignoring the Status Code: Developers often only look at the response body. If your API returns 200 OK when it should have returned 201 Created for a resource creation, your API is technically failing its contract.
  • Hardcoding URLs: In Postman, avoid hardcoding localhost:3000 directly into requests. Use "Environments" to switch between localhost and your production server easily.
  • Forgetting Content-Type: If you don't send Content-Type: application/json in your request headers, your server-side framework might fail to parse the body correctly, leading to mysterious null errors.

FAQ

Q: Should I use cURL or Postman? A: Use cURL for quick debugging and CI/CD scripts. Use Postman for complex testing, team collaboration, and maintaining a library of test cases.

Q: Does manual testing replace automated testing? A: Absolutely not. Manual testing is for discovery and initial verification. Unit testing your API endpoints is essential for long-term maintenance.

Q: Why do I get a 403 or 404 error? A: Double-check your route path (e.g., ensure you are using /v1/ as we implemented in implementing versioned routes).

Recap

We successfully verified our Task Manager API by manually sending requests and inspecting responses. By using cURL for CLI efficiency and Postman for structured validation, you can now confirm that your endpoints meet the design requirements before moving to more advanced topics.

Up next: We will discuss Error Handling Best Practices to ensure your API provides meaningful feedback when things go wrong.

Similar Posts