Как десериализовать сообщение об ошибке OData JSON? - PullRequest
0 голосов
/ 03 марта 2019

Я пытаюсь десериализовать это сообщение об ошибке odata:

enter image description here

Члены объекта для этого кода всегда равны нулю:

    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; }
}

Как получить сообщение об ошибке и сообщение об ошибке?

1 Ответ

0 голосов
/ 04 марта 2019

Попробуйте это

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; }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...