Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
#!/bin/sh
# param: $1="--retry" is a case for query once more when last query fails
send_api_request() {
query="${query} -H 'Authorization: Bearer ${access_token}'"
resp=`eval $query`
# echo -e "$query \n $resp"
# when the subshell process renews tokens and makes previous token deprecated, the above query will fail
# parse error: Invalid numeric literal at line 1, column 10 (jq has issue and throws an error here)
api_error_code=$(echo "${resp}" | jq --raw-output '.error.code')