0

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 tried

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

1

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 'https://<provider_url>/upd.php?user=<username>&pwd=<pwd>&host=<hostname>'

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.