Run GraphQL queries in Postman
Send a GraphQL API query from Postman with the endpoint, the token header, and a GraphQL body, and read the rows the API returns.
You can send GraphQL API queries from Postman and read the response next to the request. Postman sends the query as a POST request with your personal token in the Authorization header. To run a query from the browser or with curl instead, refer to the GraphQL API quickstart.
Prerequisites
- A personal token. To create one, refer to How to manage a personal token.
- Postman installed on your machine.
- A workload that received requests during the time window you query. The sample query reads its request data.
Send a query
The sample query reads workloadMetrics, an aggregated dataset of the metrics endpoint. It sums the bytes sent to clients per time bucket over seven days, oldest first, and returns at most 10 rows.
To send the query from Postman:
In Postman, select + to open a request.
Select GET to open the method list, then select POST.
In the Enter URL or paste text field, enter the metrics endpoint:
For raw data, such as workloadEvents, enter https://api.azion.com/v4/events/graphql instead. The endpoint of each dataset is on Queries.
In the Headers tab, select Bulk Edit and enter the line below. Replace [TOKEN VALUE] with your personal token:
Keep the Token prefix. With Bearer, the API returns 401 with Authentication credentials were not provided.
In the Body tab, select GraphQL.
In the query box, enter the query. Set tsRange to a window in which your workload received requests:
The dataset name httpMetrics is deprecated; use workloadMetrics, which returns the same rows.
Select Send.
Postman shows the API’s answer, 200 with the rows in JSON. The query returns up to 10 rows. The response is cut after the third:
Read the response
The data key holds one array named after the dataset, with one object per row and only the fields the query selected:
| Field | Value |
|---|---|
ts | The start of the time bucket, in UTC, marked by the Z suffix. Over a seven-day window, each bucket is one hour. |
sum | The output of aggregate: {sum: bytesSent}: the bytes sent to clients during the bucket. |
A bucket with no requests returns no row, so the rows skip the hours without traffic. The bucket size follows the length of the window, as How the GraphQL API works describes.
A refused query returns a JSON object with a single detail key that holds the message. For each message and its cause, refer to Error responses.
For more queries to run the same way, refer to aziontech/azion-queries, the Azion repository of GraphQL API query examples.