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
Post a Comment