Sending HTTP request via command line and curl
as the string given by
--data
is 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
,--get
When used, this option will make all data specified with
-d
,--data
,--data-binary
or--data-urlencode
to 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 'https://<provider_url>/upd.php?user=<username>&pwd=<pwd>&host=<hostname>'
Related videos on Youtube
Comments
-
E. Sommer over 1 year
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:
https://<provider_url>/upd.php?user=<username>&pwd=<pwd>&host=<hostname>
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 triedcurl --data "user=<username>&pwd=<pwd>&host=<hostname>" https://<provider_url>/upd.php
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