curl POST JSON Example
Send JSON with curl using the right headers, request body, and authentication pattern.
Basic POST JSON
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ada","role":"admin"}'With Bearer Token
curl -X POST https://api.example.com/users \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Ada"}'Common Mistake
If the server says it cannot parse the body, check that Content-Type is application/json and that your shell quoting did not break the JSON string.
Related
Knowledge is power.