Remy Blok
Remy Blok

Reputation: 137

Sorting SharePoint list items on creation date with Graph API

I'm working with the Beta of the Microsoft Graph API in order to access SharePoint list items. I'm trying to filter items on the creation date.

The URI i'm calling is: https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items/?$filter=createdDateTime gt '2017-09-20T00:00:00'

I end up with the following error:

{
    "error": {
        "code": "BadRequest",
        "message": "A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThan'.",
        "innerError": {
            "request-id": "4bdec409-885c-46ee-b3b6-df2c43f997ac",
            "date": "2017-09-27T08:11:22"
        }
    }
}

I've searched a lot of SO question regarding working with date type and OData, but non of the solutions work. This date format does work for other entities in de API. So this seems the right syntax for filtering on dates. Am I doing something wrong or is the a bug in the the Graph API?

Upvotes: 2

Views: 989

Answers (1)

Nelson Nyland
Nelson Nyland

Reputation: 555

The beta version of MS Graph API is being deprecated in most cases. I would recommend using v1.0.

One solution you could pursue is calling Get listItem for specific values of a listItem:

GET /sites/{site-id}/lists/{list-id}/items/{item-id}?expand=fields(select=Column1,Column2)

https://learn.microsoft.com/en-us/graph/api/listitem-get?view=graph-rest-1.0&tabs=http

Upvotes: 0

Related Questions