HTTPie http POST: JSON Bodies with = := and :=
http POST url field=value assembles a JSON request body and sets Content-Type to application/json automatically.
HTTPie's field operators are the reason people reach for it: = makes a string, := makes a raw JSON value (numbers, booleans, arrays), and == makes a query parameter.
What it does
http POST collects field=value items into a JSON object and POSTs it with Content-Type: application/json. Use = for string values, := for raw JSON (so active:=true is a boolean, not the string "true"), and == for URL query parameters. @file reads a value from a file.
Common usage
http POST example.com/api/users name=Ada role=admin active:=true
http POST :3000/api/items tags:='["a","b"]' count:=5
# send a raw JSON file as the body
http POST example.com/api/data < payload.json
# field value from a file
http POST example.com/upload token=@./token.txtOptions
| Operator / flag | What it does |
|---|---|
| field=value | String field in the JSON body |
| field:=value | Raw JSON field (number, boolean, array, object) |
| field==value | URL query string parameter |
| field:=@file.json | Embed JSON read from a file as the value |
| --raw <text> | Send this exact string as the request body |
| --form, -f | Send as form-encoded instead of JSON |
In CI
Reach for := whenever a field is not a string. A common bug is count=5 sending the string "5" and the API rejecting it; count:=5 sends the number. To post a prebuilt JSON file verbatim, redirect it in with < payload.json rather than trying to escape it into field items.
Common errors in CI
http: error: <field>: cannot parse ... as JSON means a := value is not valid JSON (unquoted string, single quotes inside, trailing comma). http: error: Request body (from stdin) and request data (key=value) cannot be mixed means you combined field=value items with a redirected body; pick one. A 415 Unsupported Media Type usually means the API wanted form data, so add --form.