#!/usr/bin/env bash set -euo pipefail API_URL="https://jmespath-playground.koszewscy.waw.pl" JSON_FILE="-" ADD_HEADERS=() function usage() { echo "Usage: $0 [--api-url ] [--json-file ]" exit 1 } while [[ $# -gt 0 ]]; do case $1 in --api-url) API_URL="$2" shift 2 ;; --api-key) ADD_HEADERS+=("-H" "X-API-Key: $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" \ "${ADD_HEADERS[@]}" \ --data @${JSON_FILE} \ "$API_URL/api/v1/upload"