PUT with JSON Body
Replace a resource with PUT
cURL Command
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Alex Updated"}' https://api.example.com/users/1Flag-by-flag explanation
- -X PUT
- HTTP PUT method for full replacement
- -H
- Content-Type header for JSON
- -d
- Request body
Python equivalent
import requests
r = requests.put("https://api.example.com/users/1", json={"name": "Alex Updated"})JavaScript fetch equivalent
await fetch("https://api.example.com/users/1", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "Alex Updated" })
});