代码之家  ›  专栏  ›  技术社区  ›  dvelopp

按开始日期对事件排序

  •  11
  • dvelopp  · 技术社区  · 8 年前

    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顺序按日期对事件排序?

    1 回复  |  直到 8 年前
        1
  •  13
  •   Marc LaFleur    8 年前

    你很接近但你在引用 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