Click here to Skip to main content
15,913,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created as web api HttpResponseMessage with http error object.
Ex:actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new HttpError { ExceptionType = "102", ExceptionMessage = "Unathorized Exception", Message = actionExecutedContext.Exception.Data["ActivityID"].ToString() });

now I need to access the http error object in web api client. for that I have created a class
public class ErrorDetails
{
public string ExceptionMessage { get; set; }
public string ExceptionType { get; set; }
public string Message { get; set; }
public string StackTrace { get; set; }
}

var error = response.Content.ReadAsAsync<errordetails>().Result;

when I try to deserialize the error object like above. getting an Aggregate exception.

Can any one help me on this. I need to access the error object
like ex : error.Exceptionmessage
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900