Sadly, sometimes requests to the API are not successful. Failures can occur for a wide range of reasons. In all cases, the API should return an HTTP Status Code that indicates the nature of the failure (below), with a response body in JSON format containing additional information.
In the event of a server error the response body will contain an error phrase.
Code | Meaning | Description |
---|---|---|
200 | Success | If data was requested, it will be available in the data field at the top level of the response body. |
201 | Success (for object creation) |
Its information is available in the data field at the top level of the response body. The API URL where the object can be retrieved is also returned in the Location header of the response. |
400 | Invalid request | This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again. |
401 | No authorization | Valid API credentials were not provided with the request, so the API could not associate a user with the request. |
403 | Forbidden | The API credentials and request syntax was valid but the server is refusing to complete the request. This can happen if you try to read or write to objects or properties that the user does not have access to. |
404 | Not found | Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist. |
500 | Server error | There was a problem on Legend's end. |
In the event of an error, the response body will contain an errors field at the top level. This contains an array of at least one error object, described below:
Example | Description |
---|---|
Message: | project: Missing input Message providing more detail about the error that occurred, if available. |
Phrase: | 6 sad squid snuggle softly 500 errors only. A unique error phrase which can be used when contacting developer support to help identify the exact occurrence of the problem in Asana’s logs. |