【问题标题】:Sort Events by Start Date按开始日期对事件进行排序
【发布时间】:2018-04-30 01:49:27
【问题描述】:

我需要能够使用 Microsoft Graph API 在 ASC/DESC 两个方向上获取事件。我正在尝试使用以下 API 来实现:

https://graph.microsoft.com/v1.0/me/events?$orderby=start

但是,当我执行请求时,我收到以下错误:

{
    "error": {
        "code": "BadRequest",
        "message": "The $orderby expression must evaluate to a single value of primitive type.",
        "innerError": {
            "request-id": "c00d676d-ef8e-418b-8561-80e08729da71",
            "date": "2017-11-16T13:31:59"
        }
    }
}

另外,我尝试直接访问日期:

https://graph.microsoft.com/v1.0/me/events?$orderby=start.dateTime

得到以下错误:

{
    "error": {
        "code": "BadRequest",
        "message": "The child type 'start.dateTime' in a cast was not an entity type. Casts can only be performed on entity types.",
        "innerError": {
            "request-id": "240342f5-d7f6-430b-9bd0-190dc3e1f73b",
            "date": "2017-11-16T13:32:39"
        }
    }
}

有没有办法按 ASC/DESC 顺序按日期对事件进行排序?

【问题讨论】:

    标签: microsoft-graph-api outlook-restapi


    【解决方案1】:

    您非常接近,但您错误地引用了DateTime。正确的格式是{parent}/{child}。这些将起作用:

    https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime
    https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime desc
    

    【讨论】:

    • 这正是我所需要的。谢谢!
    猜你喜欢
    • 2014-03-11
    • 1970-01-01
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 2013-03-17
    • 2020-10-30
    • 1970-01-01
    相关资源
    最近更新 更多