By EnableOData in an existing web api project, all the HttpError in the project will be converted to ODataError when client requests application/json.
The error payload's shape will be changed:
Before enable odata:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:8081/api/Value'.","MessageDetail":"No type was found that matches the controller named 'Value'."}
After enable odata:
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"No HTTP resource was found that matches the request URI 'http://localhost:8081/api/Value'."
}
}
}
The error payload's shape will be changed:
Before enable odata:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:8081/api/Value'.","MessageDetail":"No type was found that matches the controller named 'Value'."}
After enable odata:
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"No HTTP resource was found that matches the request URI 'http://localhost:8081/api/Value'."
}
}
}