curl on Windows and PowerShell: how to run it and why commands fail
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
Windows 10 and 11 ship curl.exe, but commands from docs often fail. Two reasons: in Windows PowerShell 5.1 the word curl is an alias for Invoke-WebRequest with different parameters, and quotes and line continuation in cmd and PowerShell differ from Linux. Below is how to run the real curl and rewrite commands.
curl or curl.exe
In cmd the curl command runs the real curl. In Windows PowerShell 5.1 curl is an alias for Invoke-WebRequest, so -H and -d fail with a parameter error. Type curl.exe explicitly. PowerShell 7 removed the alias, but curl.exe is still safer in scripts run on different machines.
Quotes and JSON
On Linux the JSON body goes in single quotes. In cmd single quotes do not work: wrap everything in double quotes and escape inner double quotes with a backslash. The most reliable way on any system is to put the JSON in a file and pass it with --data @body.json.

Continuing a long command
A trailing backslash continues a command only in bash. cmd uses ^ and PowerShell uses a backtick. When copying a command from docs or Postman, it is easier to put it on one line first.
Commands for cmd and PowerShell
REM cmd: JSON в двойных кавычках, внутренние кавычки экранированы
curl -X POST https://api.example.com/v1/orders -H "Content-Type: application/json" -d "{\"sku\":\"MON-24\",\"qty\":2}"
REM cmd: тело из файла, работает везде
curl -X POST https://api.example.com/v1/orders -H "Content-Type: application/json" --data @body.json
# PowerShell: явный curl.exe, перенос строки обратным апострофом
curl.exe -X POST https://api.example.com/v1/orders `
-H "Content-Type: application/json" `
--data "@body.json"
# PowerShell: токен из переменной
curl.exe -H "Authorization: Bearer $env:TOKEN" https://api.example.com/v1/orders
Linux, cmd and PowerShell side by side
| bash | cmd | PowerShell | |
|---|---|---|---|
| Command | curl | curl | curl.exe |
| Quotes around JSON | Single | Double, escaped | File via @ |
| Line continuation | \ | ^ | backtick |
| Variable | $TOKEN | %TOKEN% | $env:TOKEN |
Common errors
- Cannot bind parameter Headers. Invoke-WebRequest ran instead of curl; type curl.exe.
- The server answers 400 to JSON. Quotes inside the body got lost; send the body from a file.
- curl not found. An old Windows build without curl.exe; install curl from the official site.
More POST samples with JSON are in curl POST with JSON.
More on curl
Section overview and all guides: curl command cheat sheet: flags and examples for APIs.
- Download a file with curl: -o, -O, redirects and resume
- curl through a proxy: -x, environment variables, SOCKS and no_proxy
- PHP cURL: GET and POST requests with JSON, headers and error handling
- Webhook: what it is, how it works and how to test it
- curl GET request: parameters, response headers and status code
Frequently asked questions
Does Windows have curl?
Yes, Windows 10 from 1803 and Windows 11 ship curl.exe.
Why does curl fail in PowerShell?
In Windows PowerShell 5.1 curl is an alias for Invoke-WebRequest; type curl.exe.
How do I send JSON on Windows?
Escaped double quotes in cmd, or more reliably a file via --data @body.json.
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 FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
References
Start with the linked example and compare its result with your own test requirement.