Invoke-WebRequest : A parameter cannot be found that matches parameter name 'LfO'
Asked Answered
S

6

20

I'm trying to install Airflow with docker on my desktop.

When I run curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.2.3/docker-compose.yaml' like the internet says, I get this:

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'LfO'.
At line:1 char:6
+ curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.2.3/docke ...
+      ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

And I can't find any info over the web :(

Sikora answered 12/1, 2022 at 19:55 Comment(0)
D
89

This question ranks highly on Google for some reason, which means I regularly click through here when I encounter this issue. For the sake of my sanity, and anyone else who arrives here, here's the answer:

Execute this in the command prompt:

Remove-item alias:curl

Explanation: There's a CmdLet called Invoke-WebRequest which has an alias of curl. So when you execute this command, rather than using curl, it tries to use Invoke-WebRequest. Removing this alias allows you to execute curl as you intended.

Windows Terminal seems to have Invoke-WebRequest set up by default, so I occasionally find myself needing to run the Remove-item.

Dose answered 3/8, 2022 at 17:0 Comment(2)
The devil is in the details. Maybe there was good intent behind this but I feel it only adds to chaos.Phalange
wow real magic!Formless
P
0

The above answer works perfectly but for poeple who don't want to mess with powershell, just run wsl (Windows Subsystem for Linux) if you have it and let windows deal with it's own issues. This command would run without error in an Ubuntu terminal.

Persse answered 19/7, 2023 at 16:15 Comment(0)
S
0

I resolved the issue by using the -k:

curl -k -LfO 'https://airflow.apache.org/docs/apache-airflow/2.7.3/...
Scapular answered 30/11, 2023 at 11:27 Comment(0)
T
0

This is the documentation provided by microsoft https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest

I solved it by using -uri in the parameters:

curl -uri http://example.com

StatusCode        : 200
StatusDescription : OK
Content           : {123, 34, 107, 101...}
RawContent        : HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
                    Content-Security-Policy: default-src 'self';base-uri 'self';font-src 'self' https:
                    data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:...
Headers           : {[Access-Control-Allow-Origin, *], [Content-Security-Policy, default-src 'self';base-uri
                    'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self'        
                    data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https:
                    'unsafe-inline';upgrade-insecure-requests], [Cross-Origin-Embedder-Policy, require-corp],
                    [Cross-Origin-Opener-Policy, same-origin]...}
RawContentLength  : 372

As you can see the content is in binary format. If you want to see it you have to define an output file:

curl -uri http://example.com -outfile response.txt
Typhogenic answered 19/1 at 13:54 Comment(0)
F
0

If you are OK with using Invoke-WebRequest, just use it like so (assuming you did not Remove-item alias:curl):

curl -Uri http://<some-address>:<some-port>/ -Method POST -Body @{param1='my param';param2='420'}

You can also (as suggested here) do the following:

$postParams = @{param1='my param';param2='420'}
curl -Uri http://<some-address>:<some-port>/ -Method POST -Body $postParams
Fridge answered 29/3 at 7:13 Comment(0)
L
0

If you are using Windows, try this command:

Invoke-WebRequest -Uri 'https://airflow.apache.org/docs/apache-airflow/2.9.2/docker-compose.yaml' -OutFile 'docker-compose.yaml'
Lignite answered 27/6 at 5:8 Comment(1)
by putting single lines of code in single backticks (`) it will get formatted accordingly and will be more clear to the reader.Marzi

© 2022 - 2024 — McMap. All rights reserved.