Skip to content

Instantly share code, notes, and snippets.

@ivansostarko
Created May 30, 2017 10:21
Show Gist options
  • Save ivansostarko/2e4971bd2298951e7b7d7cde104610e7 to your computer and use it in GitHub Desktop.
Save ivansostarko/2e4971bd2298951e7b7d7cde104610e7 to your computer and use it in GitHub Desktop.
Logging Rest API using cURL
#!/bin/bash
# API log description
echo "Started TIME: $(date '+%d/%m/%Y %H:%M:%S')" > api.log
for i in {1..1000000}
do
echo "
Executed times: $i
str: $(date '+%d/%m/%Y %H:%M:%S.%N')" >> api.log;
curl -H "X-Authorization: api-key" --data "param_1=one&param_2=2" https://api.com/v1 >> api.log;
echo "
end: $(date '+%d/%m/%Y %H:%M:%S.%N')" >> api.log;
done
echo "Ended TIME: $(date '+%d/%m/%Y %H:%M:%S')" >> api.log
@ivansostarko
Copy link
Author

How to run script:

Rename file to .sh
chmod +x curl_rest_api_logging.sh
Edit values in curl
Run script ./curl_rest_api_logging.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment