Customizable status codes and error messages for APIs

0 Kudos

When buliding API's it would be helpful if we could create custom status messages with error codes for the benefit of the IT teams calling the API.

For example, if a feature is sent with a value that isn't in a specified range, we could send back a status 400 with a descriptive error message.

As an example: A feature 'age' is sent to the API with a value of 200, the API code checks this to a valid range (18-99) and sends back a status 400 response with an error message like 'Age out of range'.

As it is now we can check for that in the code and return a different result, but it will still send as a status 200, because the API call itself was successful. Being able to create different status codes to be sent back would help us greatly in communicating about API behavior with out IT 'customers'.

2 Comments

Duplicate of this idea:

https://community.dataiku.com/t5/Product-Ideas/API-Services-code-able-to-produce-HTTP-statuses-4xx/i...

You can also add error codes as part of your API call result. But I agree that being able to customise the HTTP codes will be a better solution.

Duplicate of this idea:

https://community.dataiku.com/t5/Product-Ideas/API-Services-code-able-to-produce-HTTP-statuses-4xx/i...

You can also add error codes as part of your API call result. But I agree that being able to customise the HTTP codes will be a better solution.

Ah, yes. Apologies.

We've indeed been adding "statuscode" and "error message" as items in the response, but it would indeed be much clearer for the recipient (and less work for us to code) if these were actual HTTP status codes

Ah, yes. Apologies.

We've indeed been adding "statuscode" and "error message" as items in the response, but it would indeed be much clearer for the recipient (and less work for us to code) if these were actual HTTP status codes