Errors
TreeScale Apps have a few error response statuses that you have to know to construct all the cases in your backend application.
The most common reason for failure is the validation errors you might get if your request body is invalid for the HTTP POST method. Our API makes deep JSON Body validation to ensure all the parameters are correct and everything exists inside the specified endpoint prompt template.
Before reaching out to support with an error, please be aware that 99% of all reported errors are, in fact, user errors. Therefore, please carefully check your code before contacting TreeScale support.
Status codes
Here is a list of the different categories of status codes returned by the Protocol API. Use these to understand if a request was successful.
- Name
200
- Type
- Description
An 200 status code indicates a successful response.
- Name
404
- Type
- Description
A 404 status code indicates that the given Endpoint doesn’t exist for that TreeScale App
- Name
401
- Type
- Description
A 401 status code indicates that the given API Key is incorrect to access the given TreeScale App
- Name
400
- Type
- Description
A 400 status code indicates a request body formatting issue. The response body should contain detailed JSON validation issues, which you can use to display for your users or extract reasons for your application logic.
- Name
500
- Type
- Description
A 500 status code indicates an unknown server error or outage. It might happen when, for example, we have a server-side problem that does not relate to how you made the request.
Error types
Whenever a request is unsuccessful, the TreeScale App API will return an error response with an error type and message. You can use this information to understand better what has gone wrong and how to fix it. Most of the error messages are pretty helpful and actionable.
Here is a list of the two error types supported by the TreeScale App API — use these to understand what you have done wrong.
- Name
code
- Type
- Description
This means that we made an error, which is highly speculative and unlikely.
- Name
expected
- Type
- Description
This property defines the expected value for the validation to pass. Sometimes this might be empty because not all values have defaults.
- Name
received
- Type
- Description
This property explains more about what was the value or type of the given variable
- Name
path
- Type
- Description
This property contains a JSON property name list to find which field failed to pass a validation inside your request body
- Name
message
- Type
- Description
This property contains a human-readable message about that specific error
Error response
{
"error": [
{
"code": "invalid_type",
"expected": "string",
"received": "number",
"path": [
"country"
],
"message": "Expected string, received number"
}
]
}