How do you upload a file to a Milton WebDAV server using curl? - webdav

When I try to curl using the -T option, I get an empty reply:
$ curl --digest -u me:pwd -H "Content-Type:application/xml" -T test.xml http://localhost:8085/
curl: (52) Empty reply from server
Anyone know the incantation? The server works fine when connecting to it from the WebDAV client built into MacOSX.

By default curl sends Expect: Continue, but unfortunately java web containers don't play nicely with the Expect header. The simplest answer is to instruct curl not to send that header:
curl --digest -u a2 -H "Content-Type:application/xml" -H "Expect:" -T TestPBE-workspace.xml http://localhost:8080/users/a2/files2/
The better solution is to make expect:continue work, but from the research i've done it appears that depends on what web container you're using.

Related

CURL chunked POST from infinite pipe?

I want to continuously post an infinite binary data stream to a webserver.
So I'm using the following command:
curl -X POST -H "Transfer-Encoding: chunked" -d 'hello' http://127.0.0.1:9000
As a test, I'm piping the output of the 'yes' command:
$ yes | curl -X POST -H "Transfer-Encoding: chunked" -d '#-' http://127.0.0.1:9000
But it doesn't even connect to the webserver, and aborts with an out-of-memory error. It seems curl is trying to read the whole file into memory before starting the transfer.
Does curl supports continuously HTTP posting data coming from a pipe? (I'm using curl version 7.61.0).
Thanks!
Try with
yes | curl -T. http://127.0.0.1:9000
But you will probably get this known bug :
https://github.com/curl/curl/issues/2051
https://github.com/curl/curl/issues/932
Or
yes | curl -T- http://127.0.0.1:9000

Equivalent http request of curl command

I'm working on OAUTH 2.0 stuff using following curl command which is working fine in my terminal.
command -
curl -u testclient1:testpass1 http://localhost/oauth2-server/token.php -d 'grant_type=password&username=bshaffer&password=brent123'
I want to know what's equivalent HTTP request for above CURL command so that, i can use guzzle(comparatively easier) to make HTTP request to get the token. I've tried a lot of combination but not getting the right way to do it.
finally after a lot of googling I managed to find out the equivalent HTTP request of that CURL command.
Here is the command -
http://testclient1:testpass1#localhost/oauth2-server/token.php?grant_type=password&username=bshaffer&password=brent123

HTTP request in Ubuntu

i need to call a HTTP request in ubuntu how do i do it? I can't seem to find an answer around on how to to do it?
How do run the following url without calling a browser like lynx to do it?
http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
in your command prompt, run the following:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
the curl command executes an http request for a given url and parameters.
if you need to specify another HTTP method, use curl -X <TYPE> <URL>, like this:
curl -X POST http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
curl documentation: http://curl.haxx.se/docs/manpage.html
to display the results:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
or
to save the results as a file
wget http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad

Curl command for issuing a POST request

I am in my Terminal and I want to send a POST request to a given URL. I have tested this with a REST client so I know that the parameters work.
So lets say I want to POST the following parameters:
username=tony
password=secret
To my URL: https://exmaple.com/login/
I tried the following curl command in my Terminal (I am using OSX Lion)
curl --data "username=tony&password=secret" http://exmaple.com/login/
I get an 500 Server Error back from the server so I am now thinking of something that could be different between the REST Client and the curl command.
Thanks for your help
Update: I am using a https service. Do I have to adjust my curl command to account for this?
Try this
curl -F username=tony -F password=secret http://exmaple.com/login/
-F (reference) should probably do the same as --data? Possible the problem is in the webapp.
Maybe the app you are hitting uses basic auth for authentication? Try this one:
curl --user name:password http://exmaple.com/login/

how to access GSA API

I have a Google Search Appliance and am trying to access the API to download the Event Logs. I am using curl through cygwin on the Windows 7 command line.
I am able to get an authentication token using
curl -X POST -d Email=username -d Passwd=password "http://ip.ad.dr.ess:8443/accounts/ClientLogin"
My problem is that when I attempt to retrieve the even logs themselves:
curl -k -X GET -d query=User -H "Content-type: application/atom+xml" -H "Authorization: GoogleLogin Auth=e73265ce254f7c4afbcbee1743a56e81" "http://10.29.5.5:8000/feeds/logs/eventLog"
curl says that it cannot reach the host:
curl: (7) couldn't connect to host
Any help in getting this to work is greatly appreciated.
Check if you can telnet to the IP-address. If you get a timeout there you should check firewalls etc.
C:\> telnet 10.29.5.5 8000
This looks like a more generic network problem than a problem with either the GSA or Curl.
The problem turned out to be the configuration with my GSA. The GSA is configured to require communication over HTTPS. Because all GSAs default to HTTP traffic over port 8000 and HTTPS traffic over 8443, my problem was solved by sending the following:
curl -k -X GET -d query=User -H "Content-type: application/atom+xml" -H "Authorization: GoogleLogin Auth=e73265ce254f7c4afbcbee1743a56e81" "https://ip.ad.dr.ess:8443/feeds/logs/eventLog"

Resources