问题描述
以下api调用为我提供了json,以便从"Office 365 Service Communications API参考"(https://msdn.microsoft.com/en-us/)中提到的消息中心获取所有消息。 office-365 / office-365-service-communications-api-reference)。
The following api call gives me the json to get all the messages from the Message Center as mentioned in "Office 365 Service Communications API reference"(https://msdn.microsoft.com/en-us/office-365/office-365-service-communications-api-reference).
https://manage.office.com/api/v1.0/mydomain.com/ServiceComms/消息
https://manage.office.com/api/v1.0/mydomain.com/ServiceComms/Messages
我需要在这个api上应用一个过滤器来获取仅包含事件的消息的json。
I need to apply a filter on this api to just get the json of only Messages excluding Incidents.
https://manage.office .com / api / v1.0 / mydomain.com / ServiceComms / Messages?$ filter = MessageType eq MessageCenter
https://manage.office.com/api/v1.0/mydomain.com/ServiceComms/Messages?$filter=MessageType eq MessageCenter
我尝试应用上述过滤器并收到以下错误。
I tried to apply the filter as above and received the following error.
HTTP 400<br>{
"error":{
"code":"malformed input","message":"Filter Value Type MessageCenter is not supported for MessageType with exception: Error while parsing enum MessageCenter"
}
}
我们是否为"MessageCenter"提供了单独的枚举值。我在这里做错了什么?
Do we have a separate enum value for "MessageCenter". What am I doing wrong here?
推荐答案
"@odata.context": "https://office365servicecomms-prod.cloudapp.net/api/v1.0/5b952ff1-536f-430c-86a2-06f37793e021/
对该端点进行经过身份验证的调用以获取元数据(架构)。
Make an authenticated call to that endpoint to get the metadata (schema).
对于MessageType属性,类型指定为:
For the MessageType property, the type is specified as:
<Property Name="MessageType" Type="Microsoft.Office365ServiceComms.ExposedContracts.MessageType" Nullable="false" />
文档中的更下方是此类型的定义:
Further down in the document is the definition of this type:
<EnumType Name="MessageType" IsFlags="true">
<Member Name="Unknown" Value="0" />
<Member Name="Incident" Value="1" />
<Member Name="PlannedMaintenance" Value="2" />
<Member Name="MessageCenter" Value="4" />
</EnumType>
最后,
指定OData过滤器中的枚举 要求您包含"命名空间""然后是枚举值。所以,回答你的问题:
Lastly, specifying an enum in OData filter requires that you include the "namespace" and then the enum value. So, to answer your question:
https://manage.office.com/api/v1.0/{{tenant-id}}/ServiceComms/Messages?
这篇关于如何筛选“Office 365 Service Communications API”中的邮件中心邮件获取仅排除事件的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!