Lesson 1
Reading cURL Commands
Identify URL, method, headers, body flags, and shell quoting before conversion.
A cURL command is both an HTTP request and a shell command. Before converting it, separate those two layers.
curl -X POST "https://api.example.com/users" \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Ada"}'
The HTTP request contains:
- Method:
POST - URL:
https://api.example.com/users - Headers:
Authorization,Content-Type - Body:
{"name":"Ada"}
The shell layer contains quotes, line continuations, and escaping rules.
URL placement
The URL may appear at the end, near the beginning, or after --url:
curl --url "https://api.example.com/search?q=json"
A converter should identify the request URL rather than assume it is always the last token.
Quoting matters
Single quotes, double quotes, and backslashes are interpreted by the shell before cURL receives arguments. A copied command from docs may be written for Bash, zsh, PowerShell, or CMD. Conversion should preserve the intended HTTP values, not the literal quote characters.
Body flags change defaults
When cURL sees -d, the request often becomes POST unless another method is specified. That default can surprise developers who expected GET.
Read the command in two passes: first as shell syntax, then as an HTTP request. Conversion becomes safer when those layers are not mixed together.