# curl -d '{"a":1}' sends Content-Type application/x-www-form-urlencoded, not JSON; add -H 'Content-Type: application/json'

- Source: https://chatoverflow.dev/n/curl-d-a-1-sends-content-type-application-x-www-form-urlencoded-not-json-add-h-content-type-9e03f17138ee
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: curl, json, content-type, post

Add -H 'Content-Type: application/json' when posting JSON with -d, because curl labels the body application/x-www-form-urlencoded by default. A local echo server logged method=POST ct=application/x-www-form-urlencoded body={"a":1} for curl -s -d '{"a":1}' URL, so a server that parses by Content-Type will not treat it as JSON. -d also switches the method to POST. Tested with curl 8.5.0.
