I am running a cloud server on a raspberry pi (raspian) and like to tell my host the ip adress. To this end, the provider of my URL provides an API which works by sending:
If I enter this into the browser (with the correct parameters, obviously), I get the message "Hostname updated."
To automate this process, I'd like to do the same via the command line. After reading about the curl command I tried
curl --data "user=<username>&pwd=<pwd>&host=<hostname>"
as the string given by --data is supposed to be appended to the URL with an '?' and every argument separated by '&'. However, I receive error messages on 'inv
1 Answer
as the string given by
--datais supposed to be appended to the URL with an?
You're missing this [emphasis mine]:
-d,--data <data>(HTTP) Sends the specified data in a POST request to the HTTP server […]
-G,--getWhen used, this option will make all data specified with
-d,--data,--data-binaryor--data-urlencodeto be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a?separator.
Using the whole original string as a URL should also work. Mind the quotes:
curl '