2014-08-29 105 views
2

我試圖從其Office 365帳戶使用REST API檢索用戶的事件,但通過「開始」字段進行篩選。例如,檢索所有日期之後將發生的事件:2014-08-29T09:13:28' 但我始終檢索此錯誤消息

{ 
    "error": { 
    "code": "ErrorInvalidUrlQuery", 
    "message": "The query parameter '$filter' is invalid.", 
    "innererror": { 
     "message": "The query parameter '$filter' is invalid.", 
     "type": "Microsoft.Exchange.Services.OData.InvalidUrlQueryException", 
     "stacktrace": " at Microsoft.Exchange.Services.OData.Web.ODataQueryOptions.Populate() 
at Microsoft.Exchange.Services.OData.ODataContext..ctor(HttpContext httpContext, Uri requestUri, ServiceModel serviceModel, ODataPathWrapper odataPath, ODataUriParser odataUriParser) 
at Microsoft.Exchange.Services.OData.Web.RequestBroker.InitializeODataContext() 
at Microsoft.Exchange.Services.OData.Web.RequestBroker.Process()", 
     "internalexception": { 
     "message": "A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.Int32' for operator kind 'Equal'.", 
     "type": "Microsoft.OData.Core.ODataException", 
     "stacktrace": " at Microsoft.OData.Core.UriParser.Parsers.BinaryOperatorBinder.PromoteOperandTypes(BinaryOperatorKind binaryOperatorKind, SingleValueNode& left, SingleValueNode& right) 
at Microsoft.OData.Core.UriParser.Parsers.BinaryOperatorBinder.BindBinaryOperator(BinaryOperatorToken binaryOperatorToken) 
at Microsoft.OData.Core.UriParser.Parsers.MetadataBinder.Bind(QueryToken token) 
at Microsoft.OData.Core.UriParser.Parsers.FilterBinder.BindFilter(QueryToken filter) 
at Microsoft.OData.Core.UriParser.ODataUriParser.ParseFilterImplementation(String filter, IEdmType elementType, IEdmNavigationSource navigationSource) 
at Microsoft.OData.Core.UriParser.ODataUriParser.ParseFilter() 
at Microsoft.Exchange.Services.OData.Web.ODataQueryOptions.Populate()" 
     } 
    } 
    } 
} 

在這裏,我已經嘗試了所有的東西:

[的ressource] = https://outlook.office365.com/

URL:[的ressource] EWS /的OData/ME /活動$濾波器=起始%20當量%20DateTime'2012-05-29T09:13:28'

url:[ressource] EWS/OData/Me/Events?$ filter = Start%20eq%20DateTime'20141 231'

網址:[的ressource] EWS /的OData/ME /活動$過濾=月(開始)%20當量%2012

,我已經嘗試了字符串字段或$ $的過濾器?選擇開始,它的工作完美,所以我認爲我的錯誤是由日期格式引起的,但我不知道如何解決它,所以如果有人能幫助我,那就太棒了!

謝謝!

+0

基於API文檔上似乎'$ filter'不支持。 http://msdn.microsoft.com/en-us/library/office/dn792114%28v=office.15%29.aspx – wdosanjos 2014-08-29 19:09:52

+1

@wdosanjos感謝您的回答,但在其文檔上,Microsoft似乎表示支持:引用:「或通過使用$過濾器OData查詢參數篩選列表」http://msdn.microsoft.com/EN-US/library/office/dn792114%28v=office.15%29.aspx#sectionSection3 – nicodri 2014-08-29 19:59:21

+0

您'再右吧。我確實嘗試了我的最終結果,儘管url語法正確,但我得到了完全相同的錯誤。我也嘗試了其他(非日期)屬性,結果相同。 – wdosanjos 2014-08-29 20:07:50

回答

3

在日期上過濾確實奏效,但您無法在OData v4規範中做所有事情。例如,這些全部爲我工作:

/Me/Events?$filter=Start eq 2014-08-28T21:00:00Z 
/Me/Events?$filter=Start ge 2014-08-28T21:00:00Z 

在它前面添加「DateTime」使它失敗。與月份功能相同。如果你堅持上面的格式,它應該適合你。

+0

Samir,can你將編輯擴展到我的答案? Event實體上沒有名爲「DateTimeStart」的屬性。 – 2014-09-23 14:21:10

+0

啊,我的錯誤我誤解了你的答案 - 其他實體上的一些屬性名稱爲「DateTimeX」,我以爲你引用了這些。我將恢復編輯 – samirahmed 2014-09-25 03:41:12

0

嗨只要增加頂部= 100或更多,無論你想從你的收件箱拉。

https://outlook.office365.com/api/v2.0/me/MailFolders/Inbox/messages/?%24select=CreatedDateTime%2cLastModifiedDateTime%2cChangeKey%2cCategories%2cReceivedDateTime%2cSentDateTime%2cHasAttachments%2cSubject%2cBody%2cImportance%2cParentFolderId%2cSender%2cFrom%2cToRecipients%2cCcRecipients%2cBccRecipients%2cReplyTo%2cConversationId%2cIsDeliveryReceiptRequested%2cIsReadReceiptRequested%2cIsRead%2cIsDraft%2cWebLink&%24top=100&%24skip=0"