Skip to content

When Curl isn't Curl

Curl in PowerShell and Curl elsewhere are not the same thing.

Scenario

Working through the Getting Started guide for Event Store.

Problem

Running this in PowerShell 5.1:

curl -i -d "@event.json" "http://127.0.0.1:2113/streams/newstream" -H "Content-Type:application/vnd.eventstore.events+json"

Gave me:

Invoke-WebRequest : Missing an argument for parameter 'InFile'. Specify a parameter of type 'System.String' and try again.

But why? Curl is set up properly (it's not telling me curl : The term 'curl' is not recognized . . .)

Explanation

By default, curl in PowerShell does not use Curl (even if Curl is installed, added to your PATH and so on). Instead, curl is an alias of Invoke-WebRequest. This means that if you run curl in PowerShell with options that aren't supported by Invoke-WebRequest, you get the error above.

Solution

There are two options:

The StackOverflow answer linked above suggests removing curl as an alias:

Remove-item alias:curl

I decided I didn't want to mess with PowerShell's commands and aliases, so I used Git Bash to run my Curl commands instead.

Hire me for a docs consultation