Sending HTTP request via command line and curl

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 --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.

(source)

Using the whole original string as a URL should also work. Mind the quotes:

curl '

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like