【问题标题】:microsoft graph api - error responses returning as plain textmicrosoft graph api - 以纯文本形式返回的错误响应
【发布时间】:2020-10-13 23:21:09
【问题描述】:

我在内部 .Net Core 3.1 webapi 中使用图形 api。但是,每次返回失败的响应时,它都会以 500 内部错误的形式返回,响应为 content-type: text/plain。

Status Code: NotFound
Microsoft.Graph.ServiceException: Code: Request_ResourceNotFound
Message: Resource '********' does not exist or one of its queried reference-property objects are not present.
Inner error:
    AdditionalData:
    date: 2020-10-13T13:44:21
    request-id: 8053255b-2f1c-4543-8de7-*******
    client-request-id: 8053255b-2f1c-4543-8de7-*******
ClientRequestId: 8053255b-2f1c-4543-8de7-*******

我正在寻找以 JSON 格式返回的响应,类似于 MS Graph Api 资源管理器,带有适当的错误代码,而不是 500 内部错误。

【问题讨论】:

标签: asp.net-core microsoft-graph-api


【解决方案1】:

我相信您正在寻找的错误在里面 Microsoft.Graph.ServiceException -> 错误 -> 代码。

如果您想要 Json 格式,您可以使用 JsonConverter 进行转换。

【讨论】:

  • 谢谢 - ServiceException 正是我忽略的难题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 2016-03-04
  • 1970-01-01
  • 1970-01-01
  • 2023-03-14
相关资源
最近更新 更多