3.4 Curl Examples
curl examples for interacting with the JSONAir API.
The examples below assume JSONAir is running at https://jsonair.example.com. Replace this with your actual server address.
Step 1 — Get a Bearer Token
curl -s -X POST https://jsonair.example.com/api/v1/jsonair/auth/token \
-H "Content-Type: application/json" \
-d '{"token": "your-plain-text-pat"}'Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 3600
}Save the access_token value for use in the requests below. You can capture it with jq:
TOKEN=$(curl -s -X POST https://jsonair.example.com/api/v1/jsonair/auth/token \
-H "Content-Type: application/json" \
-d '{"token": "your-plain-text-pat"}' | jq -r '.access_token')Step 2 — Fetch Configuration Data
Returns the configuration as a Base64-encoded string (default):
Have the server decode the Base64 before returning (returns the raw configuration):
Or decode locally using base64:
Fetch the Reload Key
Response:
Fetch the Debug Level
Response:
Handling an Expired Token
When your JWT expires you will receive a 401. Re-run the auth step to get a new token:
Last updated