[英]How do I Deserialize OData JSON Error Message?
I'm trying to deserialize this odata error message: 我正在尝试反序列化此odata错误消息:
The object members are always null for this code: 该代码的对象成员始终为null:
public static async Task<ExceptionResponse> ExceptionResponse(this HttpResponseMessage httpResponseMessage)
{
string responseContent = await httpResponseMessage.Content.ReadAsStringAsync();
ExceptionResponse exceptionResponse = JsonConvert.DeserializeObject<ExceptionResponse>(responseContent);
return exceptionResponse;
}
}
public class ExceptionResponse
{
public string Message { get; set; }
public string ExceptionMessage { get; set; }
public string ExceptionType { get; set; }
public string StackTrace { get; set; }
public ExceptionResponse InnerException { get; set; }
}
How can I get the error message and innererror message? 如何获得错误消息和innererror消息?
Try this 尝试这个
public class InnerError {
public string Message { get; set; }
public string Type { get; set; }
public string StackTrace { get; set; }
}
public class Error {
public string Code { get; set; }
public string Message { get; set; }
public InnerError InnerError { get; set; }
}
public class ExceptionResponse {
public Error Error { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.