Testing with curl and Postman

curl Cheat Sheet

CommandDoes
curl URLGET, print body
curl -i URLalso show status line and headers
curl -s URLsilent (no progress bar)
curl -H "Accept: application/json" URLsend a header
curl -X POST -H "Content-Type: application/json" -d '{...}' URLsend JSON (used from the medium level on)
curl -s URL | jqpretty-print JSON (install jq)

Tip: On Windows, use curl.exe in PowerShell (plain curl is an alias for Invoke-WebRequest there), or use Git Bash.

Postman

  1. Create a Collection called "ShopEase".
  2. Create an Environment with variable baseUrl = http://localhost:8080.
  3. Add a request: GET {{baseUrl}}/api/products and click Send.
  4. Check the status (200 OK), time, and the JSON body in the "Pretty" tab.
  5. Save every request in the collection; share it with your team or export it as JSON.
GET  {{baseUrl}}/api/products                         [ Send ]
 -------------------------------------------------------------
 Status: 200 OK     Time: 24 ms     Size: 412 B
 Body  Pretty
 [
   { "id": 1, "name": "Boat Rockerz 450", "price": 1499.00, ... },
   { "id": 2, "name": "Clean Code", "price": 599.00, ... }
 ]

Browser and IDE

For GET requests, simply open http://localhost:8080/api/products in the browser. IntelliJ IDEA (Ultimate) and the VS Code "REST Client" extension can run .http files stored next to your code:

### All products
GET http://localhost:8080/api/products
Accept: application/json

### Health
GET http://localhost:8080/ping