Tuesday, 24 February 2015

Returning custom error JSON in a Web API

Often when a Web API fails you want to return more than a HTTP status code and a string. Like a full JSON object. Yet you don't want to corrupt your original return type for normal flow.
These articles describe how you can return a different type for error scenarios:

http://blog.codeishard.net/2013/02/09/webapi-and-the-behavior-of-exceptions-and-an-alternative-configurable-way-to-deal/

http://stackoverflow.com/questions/16243021/return-custom-error-objects-in-web-api

No comments:

Post a Comment