How to Use curl for API Testing
curl is a command-line tool for making HTTP requests. It is indispensable for testing REST APIs, downloading files, and debugging web services.
Basic GET Request
curl https://api.example.com/users
POST Request with JSON Body
curl -X POST https://api.example.com/users
-H "Content-Type: application/json"
-d '{"name": "John", "email": "[email protected]"}'Set Authorization Header
curl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com/me
Save Response to File
curl -o response.json https://api.example.com/data
Show Headers Only
curl -I https://example.com