alfred uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.).
Some 4xx errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.
Error Types
Status Code
Status Response
Description
202
ACCEPTED
Everything worked as expected.
404
NOT FOUND
The requested resource doesn't exist.
Error Handling:
Here is an example of making a request to my-info endpoint with a required property in the body missing:
jsonCopy code{"statusCode":422,"message":"A logic validation has not been fulfilled","reasons": [ {"message":"balance should not be empty","path":"balance","validation":"isNotEmpty" }, {"message":"balance must be a number conforming to the specified constraints","path":"balance","validation":"isNumber" } ],"code":"VALIDATION_ERROR"}
Now, this would be an example of making the same request with an incorrect api-key.
jsonCopy code{"statusCode":422,"message":"A logic validation has not been fulfilled","reasons": [ {"message":"firstname must be a string","path":"firstname","validation":"isString" }, {"message":"firstname should not be empty","path":"firstname","validation":"isNotEmpty" } ],"code":"VALIDATION_ERROR"}
Now, in this example, lastname will not be passed, which is a required property.
jsonCopy code{"statusCode":422,"message":"A logic validation has not been fulfilled","reasons": [ {"message":"firstname must be a string","path":"firstname","validation":"isString" }, {"message":"firstname should not be empty","path":"firstname","validation":"isNotEmpty" }, {"message":"lastname must be a string","path":"lastname","validation":"isString" }, {"message":"lastname should not be empty","path":"lastname","validation":"isNotEmpty" } ],"code":"VALIDATION_ERROR"}