A worked example, rendered from real sample data. Sign in to run the tool on your own input.
POST /api/users HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer token123
{"name": "John", "email": "john@example.com"}#=== raw ===
POST /api/users HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer token123
{"name": "John", "email": "john@example.com"}
#=== curl ===
curl -X POST 'https://api.example.com/api/users' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer token123' \
--data-raw '{"name": "John", "email": "john@example.com"}'
#=== httpie ===
http POST 'https://api.example.com/api/users' \
'Content-Type:application/json' \
'Authorization:Bearer token123' \
--raw '{"name": "John", "email": "john@example.com"}'
#=== fetch ===
const response = await fetch("https://api.example.com/api/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer token123"
},
body: JSON.stringify({"name":"John","email":"john@example.com"}),
});
if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
const data = await response.json();
#=== axios ===
import axios from "axios";
const { data } = await axios.request({
method: "post",
url: "https://api.example.com/api/users",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer token123"
},
data: {
name: "John",
email: "john@example.com"
}
});
#=== python ===
import requests
url = "https://api.example.com/api/users"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer token123"
}
payload = {
"name": "John",
"email": "john@example.com"
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
p
…
Generate fetch/axios/curl code from raw HTTP request text. Part of the DevTools Surf developer suite. Browse more tools in the Developer Utilities collection.