# Headers in curl: Content-Type application/json, Accept and multiple -H

Source: https://checkcraft.ru/en/guides/curl-headers-content-type.html · updated 2026-12-02

How to pass headers in curl: the -H flag, Content-Type: application/json for JSON, Accept, several headers at once, removing a header, the --json flag.

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

Headers in curl are set with -H, one per header. The most common mistake is sending JSON without Content-Type: application/json. Then curl with -d sets the form type and the server cannot parse the body. Below is how to write headers properly and check what was sent.

Checkcraft · 24 November 2026

Get help with your first test →

## Content-Type and Accept

Content-Type tells the server the request body format. Accept tells it which response format you expect. JSON APIs usually need both. With -d and no Content-Type, curl sends application/x-www-form-urlencoded.

## The --json flag

curl 7.82 and newer has --json: it sends the body like -d and sets Content-Type and Accept to application/json. Shorter, but older curl builds lack it, so instructions for a team are safer with explicit headers.

Repeating checks like this by hand? Checkcraft saves them and reruns them in one click. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## How to see sent headers

-v prints the whole request: lines with a greater-than sign are what went to the server. Two Content-Type lines or a form type instead of JSON mean the server rightly could not read it. An empty value after the colon in -H removes a header curl adds itself.

## Commands with headers

```
# JSON с явными заголовками
curl -X POST https://api.example.com/v1/orders \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"sku":"MON-24","qty":2}'

# то же короче, curl 7.82+
curl --json '{"sku":"MON-24","qty":2}' https://api.example.com/v1/orders

# несколько своих заголовков
curl https://api.example.com/v1/orders \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-Request-Id: test-001" \
  -H "Accept-Language: ru"

# убрать заголовок, который curl ставит сам
curl -H "User-Agent:" https://api.example.com/v1/orders
```

## What the server answers without the right header

| Response | Common cause |
|---|---|
| 415 Unsupported Media Type | No Content-Type: application/json or a form type |
| 400 Bad Request | The body did not parse as JSON due to quotes or type |
| 406 Not Acceptable | Accept asks for a format the server does not serve |
| HTML instead of JSON | No Accept: application/json, the server sent a page |

On Windows quotes inside JSON often get lost, causing 400: [curl on Windows and PowerShell](https://checkcraft.ru/en/guides/curl-windows-powershell.html).

## More on curl

Section overview and all guides: [curl command cheat sheet: flags and examples for APIs](https://checkcraft.ru/en/guides/curl-cheat-sheet.html).

- [curl with authorization: Bearer token, Basic, API key and headers](https://checkcraft.ru/en/guides/curl-authorization-header.html)
- [curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them](https://checkcraft.ru/en/guides/curl-errors.html)
- [curl on Windows and PowerShell: how to run it and why commands fail](https://checkcraft.ru/en/guides/curl-windows-powershell.html)
- [Download a file with curl: -o, -O, redirects and resume](https://checkcraft.ru/en/guides/curl-download-file.html)
- [curl through a proxy: -x, environment variables, SOCKS and no_proxy](https://checkcraft.ru/en/guides/curl-proxy.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[curl man page](https://curl.se/docs/manpage.html)

## Continue with a related task

[cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell](https://checkcraft.ru/en/guides/curl-post-json.html) · [curl GET request: parameters, response headers and status code](https://checkcraft.ru/en/guides/curl-get-request.html) · [curl with authorization: Bearer token, Basic, API key and headers](https://checkcraft.ru/en/guides/curl-authorization-header.html) · [Unexpected token is not valid JSON: what it means and how to find it](https://checkcraft.ru/en/guides/json-unexpected-token.html) · [curl on Windows and PowerShell: how to run it and why commands fail](https://checkcraft.ru/en/guides/curl-windows-powershell.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/curl-headers-content-type.md
