I am trying to make a POST request using curl to retrieve exam results from the page : http://wbutech.net/result_odd.php .... I am using the following syntax but various errors are showing up (like content has moved permanently) although I am using the -L option...
curl -L --data-urlencode "semno=7&rectype=1&rollno=10400111005" http://wbutech.net/show-result.php
can anyone please post the working syntax here which works on the above said link correctly and retrieves the results?
(Sample Usage is enter roll as 10400111005 and click semester7 button under regular students...that is what I am trying to do using the above curl syntax)
Try:
curl -XPOST http://wbutech.net/show-result.php -d '{"semno": 7, "rectype": 1, "rollno": 10400111005}'
Other than 301/302 redirects, this website requires using credentials, try:
curl -u user:passwd -XPOST http://50.28.104.43/show-result.php -d'{"semno": 7, "rectype": 1, "rollno": 10400111005}'
replacing user:passwd with your real username and password.
Related
How can I send POST request with a csv or a text file to the server running on a localhost using cURL.
I have tried curl -X POST -d #file.csv http://localhost:5000/upload but I get
{
"message": "The browser (or proxy) sent a request that this server could not understand."
}
My server is flask_restful API. Thanks a lot in advance.
There are many alternate ways to accomplish this. One way is
I have used the following:
curl -F ‘data=#<file_location>’ <URL>
Eg. curl -F data=#data.csv localhost:5000/h
Your command can also be changed slightly like this
curl -X POST -H 'Content-Type: text/csv' -d #file.csv http://localhost:5000/upload
The above is one of the many ways.It can be sent either as a part of form or data, or multipart, etc. You can refer Medium Post
Curl's default Content-Type is application/x-www-form-urlencoded so your problem is probably that the data you are POSTing is not actually form data. It might work if you set the content type header properly:
-H "Content-Type: text/csv"
Though it does depend on the server.
I am new to using CURL. I am trying to connect to a SharePoint URL and pull the data in the form of json. My URL looks like this:
.../_api/web/lists/GetByTitle('titles list')/items
If I give the URL as it is without any encoding, it fails with a HTTP/1.1 400 Bad Request error.
I tried using -G and --data-urlencode like below:
curl -v -G -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle" --data-urlencode "('titles list')" -d "/items"
doing this will convert my URL to .../_api/web/lists/GetByTitle?%28%27titles%20list%27%29&/items
But it fails with HTTP/1.1 404 Not Found since using -G will append to the URL with a ? and & . Putting ? and & to append to the URL will give me a different URL and hence the 404 not found error.
I have no issues accessing other end points like ../_api/web/lists since there is no need to encode it I guess.
How do I properly encode my URL and get the data without any errors?
Any help would be appreciated. Thank you.
I was able to solve the issue by directly giving URL with the encoded characters to cURL command. Like this:
curl -v -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle%28%27titles%20List%27%29/items"
I hope this helps someone. I know I am no expert with linux or cURL and any better answers to this are welcome.
I would like to use wget, curl or even use Perl to download a copy of my projects each night from ShareLatex, but when I look at Network in Chrome, I see it redirects from /login to /projects in a successful login.
Because of the redirect I it flushes the Chrome network debug log, but if I do a wrong login attempt I can see what it sends. See below screenshot.
Question
Can anyone explain how I can figure out which string I should post in order to login?
Is the _csrf header string important?
I have no luck with
curl -s --cookie-jar cookie https://sharelatex.com/login
curl -s --cookie cookie -H 'email: my#email.com' -H 'password: mypw' https://sharelatex.com/login
as it just gives me a failed login screen.
Use -L option in curl:
curl -s -L -H 'email: my#email.com' -H 'password: mypw' https://sharelatex.com/login
I've been having trouble acquiring and changing some of the basic data available from the Nest thermostat.
Using a command line, how can I get or change individual settings or values on my thermostat?
This is a compilation from several users explaining how to retrieve or change some basic information with some of my own experiences added in. Wherever I use <VALUE>, replace that with the applicable information in your setup. If you're using Windows, you'll need something like git-scm.
The following a part of the authentication process. You'll need to have a client already made on Nest's developer page and followed the provided authorization URL to get your auth code. Run this line to get an access token:
curl --data 'code=<AUTH CODE>&client_id=<CLIENT ID>&client_secret=<CLIENT SECRET>&grant_type=authorization_code' https://api.home.nest.com/oauth2/access_token
To fetch some information about the thermostats associated with the authorization code:
curl -v -L https://developer-api.nest.com/devices/thermostats?auth=<AUTH CODE>
To fetch some information about a specific thermostat:
curl -v -L https://developer-api.nest.com/devices/thermostats/<THERMOSTAT ID>?auth=<AUTH CODE>
To fetch the target temperature in F from the specified thermostat. You can replace target_temperature_f with any other value listed under thermostat on Nest's API reference:
curl -v -L https://developer-api.nest.com/devices/thermostats/<THERMOSTAT ID>/target_temperature_f?auth=<AUTH CODE>
To change the target_temperature_f:
curl -v -L -X PUT "https://developer-api.nest.com/devices/thermostats/<THERMOSTAT ID>/target_temperature_f?auth=<AUTH CODE>" -H "Content-Type: application/json" -d "65"
To change the specific structure to away. The value here is a string so be sure to include the single quotes:
curl -v -L -X PUT "https://developer-api.nest.com/structures/<STRUCTURE ID>/away?auth=<AUTH_TOKEN>" -H "Content-Type: application/json" -d '"away"'
Credit for this is primarily to the following users:
thesimm, mccv, Nagesh Susarla, and David W. Keith.
I am sending a post request to my site as so :
curl --data "param1=value1¶m2=value2" http://mysite.com/
But the result is the entire html page (independently of the username and the password, whether they are right or wrong)
try
`curl -u username:password http://example.com`
to get logged on, or try this
curl http://username:password#example.com/?param1=xx¶m2=xx