Customizable status codes and error messages for APIs
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'.
Comments
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,111 Neuron
Duplicate of this idea:
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.
-
Antal Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 91 Neuron
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