Widgets
Retrieve a widget
Returns one widget by its id.
GET/widgets/{widget_id}
Handling a missing widget
A 404 is a normal answer, not a failure of the request. Treat it as a value:
the widget is not there. It does not mean the API key is wrong, which is a 401.
status=$(curl -s -o body.json -w '%{http_code}' \
"https://api.example.com/v1/widgets/$WIDGET_ID" \
-H "Authorization: Bearer $API_KEY")
case "$status" in
200) jq -r '.name' body.json ;;
404) echo "gone" ;;
*) jq -r '.error.code' body.json; exit 1 ;;
esac