Troubleshoot Azion API
Fix Azion API requests that fail with 401, 400, 404, or 405, using the code and the message that the error response returns.
This page lists the errors you can meet with the Azion API, each with its cause and its fix. Every error response holds an errors array. Each item carries a code, a title, a detail, a status as a string, and usually a source.
A request fails with Authentication credentials were not provided
A request answers 401, with the header WWW-Authenticate: Bearer realm="api" and this body:
The request has no Authorization header. Code 10002 and "source":{"headers":"Authorization"} name the missing header.
- Send the token header: add
Authorization: Token [TOKEN VALUE]to every request, with your personal token in place of[TOKEN VALUE]. - Use the Bearer scheme if your client needs it: the API also accepts a personal token as
Authorization: Bearer [TOKEN VALUE]. - Get a personal token: create one in Azion Console or with the Azion CLI. For the steps, refer to Manage personal tokens.
The same request then answers 200.
A request fails with Invalid authentication credentials
A request that sends an Authorization header answers 401, with the header WWW-Authenticate: Bearer realm="api" and this body:
The header is present, but the API does not accept the token it carries. Code 10001 separates this case from a missing header, which returns code 10002.
- Check the token value: compare the token in the header with the token you saved when you created it.
- Replace the token: create a personal token and send it in the header. For the steps, refer to Manage personal tokens.
With a valid token, the same request answers 200.
A list fails with Page size must be between 0 and 100
GET https://api.azion.com/v4/workspace/workloads?page_size=1000&fields=id answers 400 with this body:
The page_size query parameter is above the maximum. A list returns at most 100 items per page, and 10 when you omit page_size.
- Lower the page size: send
page_size=100or less. - Read the rest page by page: send
page=2,page=3, and so on, up to thetotal_pagesvalue of the response.
The list answers 200, and the page_size field of the response echoes the value you sent.
A list fails with Not found after the last page
A list request with a high page value answers 404. A GET with a page past total_pages, such as GET https://api.azion.com/v4/workspace/workloads?page=99, answers this body:
The page value is greater than the number of pages the list has. This 404 carries "source":{"pointer":"/data"}, and a 404 for a missing resource has none.
- Read the page count first: request page 1 and read
total_pagesandcountfrom the response. - Stop at the last page: increase
pageuntil it equalstotal_pages. With a largerpage_size, the list has fewer pages.
Every page from 1 to total_pages answers 200.
A resource request fails with Not found
A request for one resource by its ID answers 404. A GET with an ID that does not exist, such as GET https://api.azion.com/v4/workspace/network_lists/999999999, answers this body:
No resource with that ID exists in the account. A resource you deleted returns the same body: after a DELETE, a GET on the same path answers this 404. The response has no source member, unlike the 404 of a page past the end of a list.
- Find the ID in the list: list the collection, for example
GET https://api.azion.com/v4/workspace/network_lists, and copy theidfromresults. - Shorten the list: add
fields=id,nameto return only the ID and the name of each item.
With an ID from the list, the request answers 200 and returns the resource in data.
A request fails with Method not allowed
A request answers 405. A DELETE on a collection path, such as DELETE https://api.azion.com/v4/workspace/network_lists, answers with the header Allow: GET, POST and this body:
A POST on an item path, such as POST https://api.azion.com/v4/workspace/network_lists/<network-list-id>, answers with the header Allow: GET, PUT, PATCH, DELETE and this body:
The path does not take the method you sent, which meta.method names. A collection path and an item path take different methods.
- Use a method from the Allow header: the
Allowheader of the response lists the methods the path takes. - Create on the collection: send
POSTto the collection path, such as/v4/workspace/network_lists. - Change or delete on the item: send
PUT,PATCH, orDELETEto the item path, such as/v4/workspace/network_lists/<network-list-id>.
With a method from the Allow header, the request answers 200, or 201 for a create.