我尝试使用REST API从其Office 365帐户检索用户的事件,但是按字段" LastModifiedTime"进行过滤。例如,检索在日期之后将发生的所有事件:' 2014-09-19T03:45:30.4020439Z'或者' 2014-09-18T04:05:00Z'但我总是检索此错误消息:
{
"error": {
"code":"ErrorInternalServerError",
"message":"The binary operator GreaterThanOrEqual is not defined for the types
' Microsoft.Exchange.ExchangeSystem.ExDateTime' and 'System.DateTimeOffset'.",
"innererror":{
"message":"The binary operator GreaterThanOrEqual is not defined for the types
'Microsoft.Exchange.ExchangeSystem.ExDateTime' and 'System.DateTimeOffset'.",
"type":"System.InvalidOperationException",
"stacktrace":" at
System.Linq.Expressions.Expression.GetComparisonOperator(ExpressionType
binaryType, String opName, Expression left, Expression right, Boolean
liftToNull)\r\n at
System.Linq.Expressions.Expression.GreaterThanOrEqual(Expression left,
Expression right, Boolean liftToNull, MethodInfo method)\r\n at
Microsoft.Exchange.Services.OData.Model.DataEntityFilterConverter.ConvertFilterNode(QueryNode queryNode)\r\n at Microsoft.Exchange.Services.OData.Model.DataEntityFilterConverter.
ConvertFilterClause(FilterClause filterClause)\r\n at
Microsoft.Exchange.Services.OData.Model.DataEntityQueryAdpater.GetEntityQueryOptions()\r\n
at Microsoft.Exchange.Services.OData.Model.FindEventsCommand.InternalExecute()\r\n at
Microsoft.Exchange.Services.OData.ODataCommand`2.Execute()\r\n at
Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan
queueAndDelayTime, TimeSpan totalTime)"
}
}
}
以下是网址:
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge 2014-09-19T03:45:30.4020439Z
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge 2014-09-18T04:05:00Z
我认为我的错误是由日期格式引起的,但我不知道如何解决它。
请有人帮助我!
谢谢!
答案 0 :(得分:0)
您可以尝试将日期值转换为类似于以下的datetimeoffset。
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge datetimeoffset'2014-09-19T03:45:30.4020439Z'
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge datetimeoffset'2014-09-18T04:05:00Z'
或者您可以使用演员操作
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge cast(2014-09-19T03:45:30.4020439Z, Edm.DateTimeOffset)
/Me/Events?$select=Subject,Start,End,LastModifiedTime&$filter=LastModifiedTime ge cast(2014-09-18T04:05:00Z, Edm.DateTimeOffset)