Skip to content
CheckcraftDownload
Practical workflow

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.

Checkcraft ·

Get help with your first test →

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.

API call diagram: method and URL, headers, body, status and response body, logs and database

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
Layers of an API call check: status, headers, body, calculations, logs, database

Linux, cmd and PowerShell side by side

bashcmdPowerShell
Commandcurlcurlcurl.exe
Quotes around JSONSingleDouble, escapedFile 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.

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.

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 FreeDownload and first run

No sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.

References

curl for Windows · curl man page and exit codes

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.

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

No account required. We will reply by email. This is a support request, not a newsletter subscription.