SHIFT GRAPH API retrieves shifts starting between 2 dates

Etienne de Villers 25 Reputation points
2023-10-19T15:30:23.1966667+00:00

I read the documentation twice over (https://learn.microsoft.com/en-us/graph/filter-query-parameter), looked at countless blog posts, can't find a way to write this simple query.

I'm trying to retrieve a set of shifts that started in a range specified between two dates.

Documentation on filter lets me know that the "and" operator is supported, but when I craft my query such as this :

https://graph.microsoft.com/v1.0/teams/<MY TEAM ID>/schedule/shifts?$filter=sharedShift/startDateTime%20ge%202023-10-18T00:00:00.000Z%20and%20sharedShift/startDateTime%20%20le%202023-10-19T00:00:00.000Z

i get a 400 "bad request" :

{
    "error": {
        "code": "BadRequest",
        "message": "A property is allowed to appear at most once in the $filter query.",
        "innerError": {
            "date": "2023-10-19T15:25:23",
            "request-id": "9bbe42bd-bbfc-4ecb-88c4-178e9010a9f1",
            "client-request-id": "9bbe42bd-bbfc-4ecb-88c4-178e9010a9f1"
        }
    }
}

Why is that ? Is there another way to achieve the same result ?

One approach I tried is to the following, using the ending of the shift :

https://graph.microsoft.com/v1.0/teams/94d07dde-0161-407a-aee8-bd103039b618/schedule/shifts?$filter=sharedShift/startDateTime%20ge%202023-10-18T00:00:00.000Z%20and%20sharedShift/endDateTime%20%20le%202023-10-19T00:00:00.000Z

but this is not consistent. Any suggestions ?

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Etienne de Villers 25 Reputation points
    2023-10-23T19:45:39.81+00:00

    Turns out this is just not supported.

    Note

    The $filter parameter doesn't support the use of the same property more than once in a query. For example, the following query will not work: sharedShift/startDateTime ge 2019-05-09T00:00:00Z and sharedShift/startDateTime le 2019-05-09T23:59:59Z.

    https://learn.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-1.0&tabs=http#optional-query-parameters

    My workaround will be to simply use the "ge" on the startDateTime, and filter out the shifts starting past a certain date on my ETL logic. This is a bit wasteful. ;-(

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.