Filtering multiple possible values with ExtendedProperties and Office 365 REST API

梦想与她 提交于 2019-12-01 12:53:13

问题


I am trying to get a list of emails given their InternetMessageID.

For one given InternetMessageID, I can retrieve the corresponding mail following the syntax provided in Outlook documentation

 "https://outlook.office365.com/api/beta/me/messages?$filter=SingleValueExtendedProperties/any(ep:  ep/PropertyId eq 'String 0x1035' and ep/Value eq '<12.FF.36768.EE3E3365@twitter.com>' )";

Now let us say that I want to retrieve two mails with the same request I did not manage to get a successful syntax.

For example

 "https://outlook.office365.com/api/beta/me/messages?$filter=SingleValueExtendedProperties/any(ep:  ep/PropertyId eq 'String 0x1035' and (ep/Value eq '<12.FF.36768.EE3E3365@twitter.com>' or ep/value eq 'anothermailid@toto.com'))";

does not work. A BadRequest is returned with a message

The filter expression for $filter does not match to a single extended property and a value restriction.

I have tried many combination of grouping and also test with an $expand statement as suggested in this question. Is there a way to perform such kind of requests with Outlook Web Api of Graph API ?


回答1:


I just tried this as well, and I get a more informative error message:

{
  "error": {
    "code": "ErrorInvalidUrlQueryFilter",
    "message": "The filter expression for $filter on property ExtendedProperty only allows 
               [and] and [eq] operators. The equality can only be specified between 
               'PropertyId' and a constant or 'Value' and a constant (for example: 
               PropertyId eq 'value')."
  }
}

UPDATE: Checked with my engineering team, and this error refers to what is inside the ANY statement. You can't use OR in there. So to make this work, you need two separate ANY statements joined by an OR:

https://outlook.office.com/api/beta/me/messages?$filter=
  SingleValueExtendedProperties/any(ep: ep/PropertyId eq 'String 0x1035' 
                                    and ep/Value eq 'someid@somedomain') or 
  SingleValueExtendedProperties/any(ep: ep/PropertyId eq 'String 0x1035' 
                                    and ep/Value eq 'otherid@otherdomain')


来源:https://stackoverflow.com/questions/33938466/filtering-multiple-possible-values-with-extendedproperties-and-office-365-rest-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!