- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 Office 365 管理 API 获取元数据。当我调用以下网址时
resource = "https://manage.office.com/api/v1.0/tenant-id/ServiceComms/Messages"
我收到响应,在内容中,我有以下信息(我已将租户 GUID 替换为名称):
{
"@odata.context": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata#Messages",
"value": [
{
"@odata.type": "#Microsoft.Office365ServiceComms.ExposedContracts.Message",
"@odata.id": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/Messages('LY177449')",
"@odata.editLink": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/Messages('LY177449')",
"AffectedWorkloadDisplayNames@odata.type": "#Collection(String)",
"AffectedWorkloadDisplayNames": [],
"AffectedWorkloadNames@odata.type": "#Collection(String)",
"AffectedWorkloadNames": [
根据响应,我假设我可以从 https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata
但是当我对该 Url 进行身份验证调用时,我只会收到内部服务器错误消息
string resource =
"https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata";
using(HttpClient httpClient = new HttpClient())
{
httpClient.Timeout = new TimeSpan(0, 2, 0);
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _authResult.AccessToken);
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
HttpResponseMessage response = await httpClient.GetAsync(resource);
}
在 httpClient
中,我有 2 个 header ,Authorization: bearer token
(工作正常)和 Accept: application/json
/p>
在 HttpResponseMessage 响应
中,我得到一个 500 Internal Server Error
。没有其他信息。
我不明白我在这里做错了什么。有谁知道如何从 Office 365 服务通信 API 获取元数据?
最佳答案
我建议您检查响应的内容,看看它是否提供了任何其他信息。
例如
When the service encounters an error, it reports the error response code to the caller, using standard HTTP error-code syntax. As per OData V4 specification, additional information is included in the body of the failed call as a single JSON object. The following is an example of a full JSON error body:
{
"error":{
"code":"AF5000. An internal server error occurred.",
"message": "Retry the request."
}
}
引用 Office 365 Service Communications API reference (Preview): Errors
当我测试您的示例 URL 时
https://office365servicecomms-prod.cloudapp.net/api/v1.0/tenant-id/$metadata#CurrentStatus
我得到一个空引用异常
System.NullReferenceException: Object reference not set to an instance of an object.
at Autofac.Integration.WebApi.AutofacWebApiFilterProvider.GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.<ReverseIterator>d__75`1.MoveNext()
at System.Web.Http.Controllers.HttpActionDescriptor.<RemoveDuplicates>d__3.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.<ReverseIterator>d__75`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Web.Http.Controllers.HttpActionDescriptor.InitializeFilterPipeline()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Web.Http.Controllers.HttpActionDescriptor.GetFilterGrouping()
at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Office365ServiceComms.MessageHandlers.RequestResponseLogHandler.<SendAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
这是意料之中的,因为我没有租户 ID 也没有授权 token 。
并且由于此 API 处于预览状态,因此很可能是他们方面的实际问题/错误。如果他们有这种能力,应该考虑提出问题。
当我测试 odata examples at odata.org ,调用 odata.context
按预期从他们的示例中返回架构。
关于c# - 通过 odata.context Url 获取 Office 365 Service Communications API 的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56596635/
我有兴趣了解有关 Microsoft Office Communicator 的更多信息IM 客户端,以及它如何确定您的存在(即您是在计算机旁还是不在)。任何人都可以向我指出解释这一点的教程或 API
我正在使用 python。我正在尝试运行一个进程并使用 subprocess.popen 获取输出。阅读周围后,我看到人们使用 communicate()[0] 但那不在文档中,它用于示例。我想知道是
我正在使用 python。我正在尝试运行一个进程并使用 subprocess.popen 获取输出。阅读周围后,我看到人们使用 communicate()[0] 但那不在文档中,它用于示例。我想知道是
我有一些设置和拆卸脚本,它们使用 csrun.exe 为一些自动化测试准备本地计算模拟器。 C:\Program Files\Microsoft SDKs\Azure\Emulator\csrun.e
我想知道对这句名言最接地气的解释是什么: Don't communicate by sharing memory; share memory by communicating. (R. Pike) 在
(所以 this question has been asked before ,但在一般意义上,大多数响应都是在与多个服务器/客户端/等的一般网络通信的上下文中) 在简单的点对点通信协议(proto
我正在尽力将 C++ 模块链接到 python 绑定(bind)。我正在努力实现 boost mpi 通信。我正在将 boost.mpi.world 对象发送到 C++,它需要一个 boost::mp
情况是这样的: 我有一个正在运行的命令: import subprocess foo = subprocess.Popen('ls /', shell=True, stdout=subprocess.
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 7年前关闭。 Improve t
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 2年前关闭。 Improve t
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 5 年前。 Improve
我曾与那些与同龄人在线聊天的人一起工作,他们不断地围绕想法进行讨论。我也曾与那些坚决拒绝并认为这是浪费时间的人一起工作。 在线实时聊天论坛对您特别有用吗?为什么或者为什么不? 在您的公司内部,还是在外
我在一个分为两组的 IT 部门工作。一组开发和管理应用程序,另一组管理公司的基础设施和服务器。我们面临的问题之一是沟通中断。我为应用程序组工作,我遇到的问题之一是当基础设施关闭服务器或刷新数据库时没有
我的团队与 IM 进行了很多交流。我们有时甚至会使用 IM 向在下一个立方体中的人提问。这样做的原因是我们都发现接听 IM 的干扰比说话要少得多。 尽管如此,我发现当我低头编码时,闪烁的消息窗口可能会
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 3年前关闭。 Improve t
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
传输数据时,汉明码显然允许您重新创建已通过线路损坏的数据(纠错码)。 这是如何工作的,它的局限性是什么(如果有的话)? 有没有更好的纠错解决方案(相对于重传)?是否存在重传更好的情况? 最佳答案 让我
我是一名优秀的程序员,十分优秀!