I have this very long and heavy DigitalOcean API command to rebuild droplet (I have a mistake there which I’m trying to figure out but it’s just for example to longevity problem).
I think it would be better of to work with multi-lined, because in one long row it’s just extremely uncomfortable to maintain. For example, look how long this one liner is:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 81206074d17245ba5d106d788b9edfea9947b1712ab47efgd6888e67f2e79957" -d '{"type":"rebuild","image":"ubuntu-16-04-x64"}' "https://api.digitalocean.com/v2/droplets/3164450/actions"
Maybe it’s best to do:
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 81206074d17245ba5d106d788b9edfea9947b1712ab47efgd6888e67f2e79957" \
-d '{"type":"rebuild","image":"ubuntu-16-04-x64"}' \
"https://api.digitalocean.com/v2/droplets/3164450/actions"
Maybe something extra (a bash function? a Bash script?)
Please share any tip, thanks!
P.S. I’ve already deleted that token, I just gave it for the example here.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Breaking it up into multiple lines definitely makes it more readable and easier to understand. You might also be interested in looking at the doctl command line tool. The same command using it would be:
If you’re are using it in a script, you can also pass
--output json
in order to have the same JSON response you would receive using cURL.