As you can see, curl -xget is working fine in PS 7.2 and cmd, but gives an error in PS 5.1.
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'xget'.
What am I doing wrong?
When you are calling curl in cmd and PowerShell Core it is calling the executable in %SYSTEMROOT%\System32\curl.exe while in PowerShell Desktop it is calling the Invoke-WebRequest command which does not have the xget parameter
If you want to use xget in PowerShell you have to use the curl.exe command instead
-X ≈ --request
-x ≈ --proxy
Maybe you should've used the capital letters in -XGET.
Related
I am trying to upload a single file via curl from within a gitlab-shell-runner.
Basically I need to use this command:
curl --user <user:password> --insecure --upload-file <file> https://example.com
Following error is shown:
Invoke-WebRequest : A positional parameter cannot be found that accepts argument "<user:password>"
Which adjustments do I need to make, to run this inside gitlab-ci?
I have already tried to use a variable for the address and different variation of quotations.
Thank you in Advance!
As mentioned in "Running cURL on 64 bit Windows" you are running a CmdLet called Invoke-WebRequest, which has a curl alias in Powershell.
Start by removing it:
Remove-item alias:curl
Then check if your script does call the actual curl command (or you might need to call it explicitly).
Or: use Invoke-WebRequest (aliased 'curl') with a Basic $encodedCredentials header.
I have a very simple curl command, this works for me (not using basic auth- the service just expects the token to be in URL):
curl -v -X POST https://Dkdjhf928hfDJFSDFJSK#sonarcloud.io/api/projects/create -d "name=sdfsdfsdf&project=sdfsdfdsf&organization=zzzzz"
This does not work:
Invoke-WebRequest -Method POST `
-Body 'name=sdfsdfsdf&project=sdfsdfdsf&organization=zzzzz' `
-Uri 'https://Dkdjhf928hfDJFSDFJSK#sonarcloud.io/api/projects/create'
powershell must be mangling something because I get this error:
Invoke-WebRequest : {"errors":[{"msg":"Insufficient privileges"}]}
Is there some default way curl sends body or data that powershell does not?
I am using the following command to upload file to an endpoint
curl -X POST -H "authorization: Basic base64encode" -H "Content-Type:
multipart/form-data" -H "X-Atlassian-Token: nocheck" -F
"file=#c:/Users/User/Desktop/testresults.xml" https://jira.test-
server.ag/rest/api/latest/issue/man-287/attachments
the command under mac works without problems, under windows I become the following error
curl: (26) read function returned funny value
curl version
curl 7.64.0 (x86_64-w64-mingw32) libcurl/7.64.0 OpenSSL/1.1.1a
installed using https://chocolatey.org
I ran into the same problem when I used curl on the Windows Subsystem for Linux on Windows 10. I had to change the path from C:\Temp\File.txt to /mnt/c/Temp/File.txt.
Check if you can access the file in your shell e.g. with dir c:\path\to\file.txt and if it fails then you know that you have to fix the path first.
I'm new to cURL, just got it installed but it seems to only do what it feels like. I'm using the 64 bit version I got from here: http://curl.haxx.se/latest.cgi?curl=win64-ssl-sspi with installation instructions I found here: http://guides.instructure.com/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine. Opening a new Powershell window I'm able to use a simple GET request like so:
curl http://localhost:3000
but if I run a POST
curl -d "hello world" http://localhost:3000
it tells me "Invoke-WebRequest : Parameter cannot be processed because the parameter name 'd' is ambiguous. Possible matches include: -DisableKeepAlive -Debug."
Trying to get help I type
curl -h or curl --help
gives me "Invoke-WebRequest : Missing an argument for parameter 'Headers'. Specify a parameter of type 'System.Collections.IDictionary' and try again."
As I mentioned, I'm a cURL newbie but it seems strange that it can do get requests but nothing else. Any ideas what I'm doing wrong?
Windows 7 64 bit
Powershell version 4
Your problem is that your are not using the Curl you installed but a CmdLet called Invoke-WebRequest.
Just execute :
Remove-item alias:curl
And test your curl again, then store it in your profile.
The explanation is that it exists a native alias to the Invoke-WebRequest which is a CmdLet that is supposed to deliver a kind of curl service.
From Windows 10 build 17063 and later (April 2018), Curl is included into Windows, so that you can execute it directly from Cmd.exe or PowerShell.exe. To use it in PowerShell be careful to unalias this CmdLet or explicitly call curl.exe.
Built with Schannel (Microsoft's native TLS engine), libcurl still perform peer certificate verification, but instead of using a CA cert bundle, it uses the certificates that are built into the OS.
You can execute curl commands with Command Prompt instead of Windows Powershell. Command prompt doesn't alias curl commands like Windows Powershell does.
To open command prompt, hit Win + R, type cmd in the input box, <Enter>.
I need to post XML data via curl.exe under windows using PUT request.
In the curl help I found:
-d/--data <data> HTTP POST data (H)
What should I supply for <data>?
curl sample calls
# with inlining plain data
curl -X PUT -d "payload" http://localhost
# referrring file
curl -X PUT -d #myXmlFile.xml http://localhost
If your windows curl-port does not support it go for cygwin. It is a linux-like environment for windows and also offers "a proper" curl.
In windows, if a double-quoted argument itself contains a double quote character, the double quote must be doubled.
For example, enter 'This is "quoted" payload' as "This is ""quoted"" payload" which is very different than in Unix.
Example:
curl -X PUT -d "This is ""quoted"" payload" http://localhost
in windows you'll need to put the # inside the quotes for the file you're sending:
curl -XPUT --data-binary "#uploadme.txt"
otherwise you'll get weird errors as it tries to use the content of the file as the url:
curl: (6) Couldn't resolve host 'upload'
curl: (6) Couldn't resolve host 'me!'
(uploadme.txt contains "upload me!")
on Windows CMD, curl refers to C:\Windows\System32\curl.exe so you can use
curl -X PUT -d "payload" http://localhost
instead on Windows PowerShell curl refers to Invoke-WebRequest so it is not working with curl syntax. you can use curl.exe on PowerShell to call C:\Windows\System32\curl.exe so it will solve the issue.
curl.exe -X PUT -d "payload" http://localhost