Skip to main content

Helpful Reference: Using cURL

I create endpoints a lot for other systems (or end users) to call and get some data or to start a process. Because of this, cURL is something I use to test my code quite often. I also like to add an example cURL call to my javadoc comments for each endpoint class.

Note: cURL can be used for other data transfers (e.g. FTP, POP3, SMTP, etc.). (see https://curl.haxx.se/docs/manpage.html)

Example cURL calls:

POST

with parameters:

curl -X POST
-d "param1=1" -d "param2=textVal" \
http://localhost:9090/server/api/endpoint

with file upload and parameters:

curl -X POST -H "Content-Type: multipart/form-data" \
-F "file=@file.txt" -F "param1=1" -F "param2=textVal" \
http://localhost:9090/server/api/endpoint/upload

GET

with parameters:

curl 'http://localhost:9090/server/api/search?id=1&val=foo'

Comments

Popular Posts

On Working On A Passion through Sourdough - It's All In The Details

"Working hard at something you don't believe in is called stress. Working hard at something you do believe in is called passion" - Simon Sinek Java programming is one of my passions, and has been for the last 15+ years. I have a few other passions - like gardening, baking, crocheting, and knitting - but Java has been a solid feature in my life, one way or another. In April of this year, as a pandemic started to rear its ugly head, I was offered an opportunity to grow another passion - a sourdough starter. My past credentials for bread-making have been dabbling in yeast breads, with the active dry variety, and quick breads; I have never worked with wild yeast. I realized an ember of passion was lit in me at the very beginning when I spent hours researching about sourdough starters the day before I was going to pick it up - what is it? how do I keep it alive? how do I make bread out of it? Will it attack me at night? By the time I had the starter in my hands, I had a recipe...