-
-
Save kmwhite/56fdf20a266ef3449c8bcc6b8213f07f to your computer and use it in GitHub Desktop.
json curl wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -x | |
CURL_BIN="$(which curl)" | |
[ -z "$CURL_BIN" ] && echo "cURL must be installed for use!" && exit 255 | |
[ -z "$1" ] && echo "A HTTP Method is Required to call" && exit 1 | |
METHOD="-X $1" | |
[ -z "$2" ] && echo "A URL is required to use" && exit 2 | |
URL="$2" | |
if [ -z "$3" ]; then | |
$CURL_BIN -qi -o - -H "Content-Type: application/json" -H "Accept: application/json" $JC_EXTRA_HEADERS $METHOD $URL | |
else | |
DATA="-d @${3}" | |
$CURL_BIN -qi -o - -H "Content-Type: application/json" -H "Accept: application/json" $JC_EXTRA_HEADERS $METHOD $DATA $URL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment