Troubleshoot Azion API
Fix Azion API v6 requests that fail with 401, 400, 404, 405, 406, or 409, 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, and a status as a string, and can carry a source and a meta object.
A request fails with Authentication credentials were not provided
A request to a path under /v6/workspace/ 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. Under /v6/deployments, /v6/environments, and /v6/resource_usage, the same request returns code 10002 with no source.
- Send the token header: add
Authorization: Token [TOKEN VALUE]to every request, with your personal token in place of[TOKEN VALUE]. - Get a personal token: create one in Azion Console. For the steps, refer to Manage personal tokens.
The same request then answers with a success status.
A request fails with Invalid authentication credentials
A request to a path under /v6/workspace/ or /v6/variables 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 credential 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.
- Check the scheme: send the token after
TokenorBearerand one space. The API takes a personal token with either scheme, and an access token fromPOST /v6/account/auth/loginwithBearer. - 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 with a success status.
A request fails with Invalid token
A request to a path under /v6/deployments, /v6/environments, or /v6/resource_usage that sends an Authorization header answers 401 with this body:
The API does not accept the credential that the header carries. On these paths, a rejected token returns code 10002 with the detail Invalid token, and the response has no WWW-Authenticate header.
- Check the token value and the scheme: apply the fixes of the previous section.
- Keep the request ID:
meta.requestIdidentifies the request when you contact support.
With a valid token, the same request answers with a success status.
A request fails with Could not satisfy the request Accept header
A request to a path under /v6/workspace/ or /v6/variables with Accept: application/xml answers 406 with this body:
The Accept header asks for a format that the API does not return. The API returns JSON. Under /v6/deployments and /v6/environments, the API returns JSON whatever the Accept header asks for.
- Ask for JSON: send
Accept: application/json.
The same request then answers with a success status and a JSON body.
A request fails with Method not allowed
A request with a method that the path does not take answers 405. A GET on https://api.azion.com/v6/account/auth/login answers with the header Allow: POST, OPTIONS and this body:
The path exists, but it does not take that method. The Allow header of the response lists the methods it takes. A collection path, such as /v6/workspace/network_lists, takes GET and POST. An item path, such as /v6/workspace/network_lists/<network-list-id>, takes GET, PUT, PATCH, and DELETE.
- Use a method from the
Allowheader: send the request again with one of the methods the header lists. - Check the path: a create goes to the collection path, and a read, a change, or a delete goes to the item path.
With a method the path takes, the request answers with a success status.
A list fails with Invalid Selected Choice
A list request whose ordering names a field that the list does not accept answers 400. The list of network lists, GET https://api.azion.com/v6/workspace/network_lists?ordering=unknown_field, answers with this body:
The list sorts only by the fields that its reference names. meta.input echoes the value you sent, and meta.choices lists the accepted fields.
- Pick a field from
meta.choices: send the request again with one of the fields the error lists, such asordering=name. - Check the reference: the Azion API reference lists the
orderingfields of each list.
With an accepted field, the list answers 200 in that order.
A list fails with Invalid Page Size
A list request, such as GET https://api.azion.com/v6/workspace/network_lists?page_size=101, answers 400 when page_size is out of range:
The page_size query parameter is outside the range that the list accepts, from 1 to 100. The detail says 0, but page_size=0 returns the same error. A list of versions, such as /v6/workspace/network_lists/<network-list-id>/versions, takes the same range.
- Send a page size from 1 to 100:
page_size=100returns the most results per page. Withoutpage_size, a list returns 10 results per page. - 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, with up to that number of results on the page.
A resource request fails with Not found
A request for one resource by its ID answers 404 with 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. A list request whose page is past the last page returns code 10004 too, with source.pointer set to /data.
- Find the ID in the list: list the collection, for example
GET https://api.azion.com/v6/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 version request fails with Version Not Editable
A PUT or a PATCH on a version, such as PATCH https://api.azion.com/v6/workspace/network_lists/<network-list-id>/versions/<version-id>, answers 409 with this body:
Only a version in the draft state takes changes. The version you sent is in another state, such as ready, which the version_state field of the version shows.
- Create a draft from that version: send
POSTto theversionspath of the resource, with the ID of that version insource_version. Withoutsource_version, the API clones the latest ready version. - Edit the draft: send the
PUTor thePATCHto the new version. - Change the resource instead: a
PATCHon the resource path, such as/v6/workspace/network_lists/<network-list-id>, opens a new draft with the change. The response carries theversion_idof that draft.
The change to the draft answers 200.
A version request fails with Version Already Built
A POST on the build action of a version answers 409 with this body:
The version is already built, or its build is in progress.
- Wait for a build in progress: read the version and check its
version_state. - Build a new version: create a draft from the built version, change it, and build the draft.
The build of a draft answers 202.
A version request fails with Max Drafts Exceeded
A POST on the versions path of a resource, or on the revert action of a version, answers 409 with this body:
The resource already has the maximum number of versions in the draft state. A network list takes up to 20 drafts.
- Build a draft: send
POSTto thebuildaction of a draft, so it leaves thedraftstate. - Delete a draft you do not need: send
DELETEto that version. The API answers202, and the version moves to thedeletedstate.
With fewer drafts, creating a version answers 201.