Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort Events by Start Date

I need to be able to get the events in both directions ASC/DESC using Microsoft Graph API. I'm trying the following API to achieve that:

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

However, when I perform the request I get the following error:

{
    "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"
        }
    }
}

Also, I tried to access the date directly:

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

Got the following error:

{
    "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"
        }
    }
}

Is there a way to sort events by date in ASC/DESC order?

like image 566
dvelopp Avatar asked Nov 16 '17 13:11

dvelopp


1 Answers

You're very close but you're referencing DateTime incorrectly. The proper format is {parent}/{child}. These will work:

https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime
https://graph.microsoft.com/v1.0/me/events?$orderby=start/dateTime desc
like image 187
Marc LaFleur Avatar answered Oct 22 '22 01:10

Marc LaFleur