POST XML

Send XML body with POST

cURL Command

curl -X POST -H "Content-Type: application/xml" -d '<user><name>Alex</name></user>' https://api.example.com/users

Flag-by-flag explanation

-H "Content-Type: application/xml"
Sets XML content type
-d
XML string as body

Python equivalent

import requests
xml = "<user><name>Alex</name></user>"
r = requests.post("...", data=xml, headers={"Content-Type": "application/xml"})

JavaScript fetch equivalent

await fetch("...", {
  method: "POST",
  headers: { "Content-Type": "application/xml" },
  body: "<user><name>Alex</name></user>"
});

Related cURL examples

Tools

cURL Generator →