The command
curl.exe -H "Content-Type: application/json" -d "{\"name\":\"Ada\"}" https://httpbin.org/post
What the flags do
| Flag | What it does |
|---|---|
curl.exe | Always type the .exe in PowerShell to get the real curl. |
-d @file.json | Read the body from a file and avoid quoting altogether. |
-o NUL | Discard output. The Windows equivalent of /dev/null. |
--ssl-no-revoke | Skip certificate revocation checks, which fail behind some corporate proxies. |
curl versus curl.exe
Windows 10 version 1803 and later include curl.exe in System32. In cmd.exe, typing curl runs it. In Windows PowerShell 5.1, curl is an alias for the unrelated Invoke-WebRequest cmdlet, which understands none of curl's flags, hence errors such as "Cannot bind parameter 'Headers'". Typing curl.exe bypasses the alias. PowerShell 7 removed the alias, so there curl means curl.
Get-Command curl # shows Alias -> Invoke-WebRequest on PowerShell 5.1
curl.exe --version # the real thing
Quoting in cmd.exe
cmd does not treat single quotes as quotes. A JSON body wrapped in single quotes arrives at curl in pieces. Use double quotes around the argument and escape each inner double quote with a backslash. Line continuation is a caret, not a backslash.
curl -X POST https://httpbin.org/post ^
-H "Content-Type: application/json" ^
-d "{\"name\":\"Ada\",\"role\":\"admin\"}"
Quoting in PowerShell
PowerShell does have single-quoted strings, but Windows PowerShell 5.1 strips inner double quotes when it hands arguments to a native program, so JSON still needs its quotes escaped with backslashes. PowerShell 7.3 and later pass them through unchanged. Line continuation is a backtick. Because the rules depend on the version, the dependable approach is a file.
# works in every PowerShell version
'{"name":"Ada","role":"admin"}' | Set-Content body.json
curl.exe -H "Content-Type: application/json" -d "@body.json" https://httpbin.org/post
# Windows PowerShell 5.1 inline
curl.exe -H "Content-Type: application/json" -d '{\"name\":\"Ada\"}' https://httpbin.org/post
Common mistakes
- The built-in curl uses Schannel, Windows' own TLS stack, so it trusts the Windows certificate store and ignores a
--cacertbundle in some configurations. @is special in PowerShell. Quote arguments such as"@body.json"and"file=@photo.png".- Git Bash and WSL behave like Linux. There the bash examples work as written, including single quotes.
Related curl examples
How to Use Curl
Curl is a command-line program that makes network requests and prints what comes back.
Curl POST JSON Example
Sending JSON takes two things: the JSON itself and a header saying that is what it is.
Curl Flags Example
Curl has well over two hundred options.
Curl HTTPS Request Example
An https:// URL is all curl needs to use TLS, and it verifies the server's certificate by default.
All Curl Examples
49 worked examples, grouped by what you are trying to do.
More under Reference
References
- curl for Windows — Official Windows builds from the curl project.
- curl man page — The option reference, identical on every platform.
These links leave api-tester.com, which is independent of the projects they point to.
FAQ
Is curl installed on Windows?
Yes. Windows 10 version 1803 and later, and Windows 11, include curl.exe. Run curl.exe --version to confirm.
Why does curl not work in PowerShell?
In Windows PowerShell 5.1, curl is an alias for Invoke-WebRequest, which does not accept curl options. Run curl.exe instead to use the real curl.
How do I send JSON with curl on Windows?
In cmd, wrap the JSON in double quotes and escape inner quotes with backslashes. The most reliable method in any shell is to put the JSON in a file and send it with -d @file.json.