Designing and Documenting an API with Swagger: curl commands don't work


whenever I try to execute the curl testing commands, like this one,

curl --header "Content-Type: application/json" -d "@new_order.json" http://localhost:3000/neworder

I always get an error in my console :

Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'Content-Type: application/json'.
At line:1 char:1
+ curl --header "Content-Type: application/json" -d "@new_order.json" h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Does anyone know the root cause and how I can fix it ?

Thank you,
Johan (Belgium)

Never mind.

I found the solution myself . It seems that my default Visual Studio Code installation is not using the Curl you installed but a CmdLet called Invoke-WebRequest .

I needed to execute first :

Remove-item alias:curl

And the rerun the commands.

Now it works !


1 Like