Friday, June 3, 2022

[SOLVED] "Positional Parameter" error when posting data with cURL

Issue

If I were to issue the command without the --data "...", it works just fine. I've tried Google and I can't find any answers to this problem. Following the directions located href="https://guides.instructure.com/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine" rel="noreferrer">here I'm getting the following errors when I attempt to post data with cURL:

PS C:\Users\David> curl --data "SMethod=0" "http://localhost/terra/modules/scripts/Query.php"
Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'SMethod=0'.
At line:1 char:1
+ curl --data "SMethod=0" "http://localhost/terra/modules/scripts/Query.php"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Solution

Your problem is answered here: Running cURL on 64 bit Windows

You're not running curl you're running something called Invoke-WebRequest, which is aliased to curl. You need to unalias curl, download and install curl (if you haven't already).



Answered By - Phill Treddenick
Answer Checked By - Terry (WPSolving Volunteer)