rwxrob-dot/snippets/bash/curlgl

19 lines
439 B
Plaintext
Raw Normal View History

2022-02-09 07:29:05 +00:00
# curl a graphql query (change /tmp/gitstoken)
curlgl () {
declare uri="$1"
shift
declare q=$(argsorin "$@")
q=${q//\"/\\\"} # escape all the double quotes
q=${q//$'\n'/ } # force single line
q=${q//$'\t'/ } # remove random tabs
declare query='{"query": "'$q'"}'
curl -s -X POST \
-H "Authorization: Bearer $(</tmp/gitstoken)" \
-H 'Content-Type: application/json' \
-d "$query" "$uri" && echo
return $?
}