POST with JSON Body
Send a JSON payload with POST
cURL Command
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alex"}' https://api.example.com/usersFlag-by-flag explanation
- -X POST
- Specifies the HTTP method
- -H
- Adds a header (Content-Type for JSON)
- -d
- Sends the request body
Python equivalent
import requests
r = requests.post("https://api.example.com/users", json={"name": "Alex"})JavaScript fetch equivalent
await fetch("https://api.example.com/users", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "Alex" })
});