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

https://www.codecademy.com/paths/fscj-22-back-end-development/tracks/fscj-22-api-development-with-swagger-and-openapi/modules/wdcp-22-design-and-document-apis-with-openapi-swagger-b5ed0e68-16f7-478f-9bed-847803b52b3b/articles/designing-and-documenting-an-api-with-swagger

Hello,

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 !

Johan

1 Like