Hi,
I am trying to find the best way to pass exceptions or messages from my Odata Service back to an Odata web forms client.
On the service, when I call this controller:
public async Task<ihttpactionresult> Post(Products product)
{
var message = "Product with id = not found";
throw new HttpResponseException(
Request.CreateErrorResponse(HttpStatusCode.NotImplemented, message));
}
It throws a HttpResponse exeption with the HttpError in the content as expected.
However, on the client side, the exception arrives as either a DataServiceRequestException or DataServiceQueryException and the inner exception message is formatted as follows:
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"Product with id = not found"
}
}
}
So, how do I easily extract the message from the JSON?
Is this the best way to do it?
Should I just return a response code and put the message in the headers?
Does anyone have an example of a webforms client with error management that they can point me to please?
I have spent hours on this and don't know what to do.
Thanks
Jeff