Files
jmespath-playground/bin/upload-jmespath

42 lines
778 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
API_URL="https://jmespath-playground.koszewscy.waw.pl"
JSON_FILE="-"
function usage() {
echo "Usage: $0 [--api-url <url>] [--json-file <file>]"
exit 1
}
while [[ $# -gt 0 ]]; do
case $1 in
--api-url)
API_URL="$2"
shift 2
;;
--json-file)
JSON_FILE="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unknown argument: $1"
usage
exit 1
;;
esac
done
# Send the POST request
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data @${JSON_FILE} \
"$API_URL/api/v1/upload"