简体   繁体   中英

How to filter response with query parameters on POST methods on Microsoft Graph API?

I am attempting to make a simple room booking application within my office. Users can select a time frame, see the available rooms, and book the room (create an event in their calendar in that time frame in that room).

In order to see what rooms are available, I am attempting to use the Microsoft Graph REST API, and specifically the POST method - getSchedule .

An example request for getSchedule looks like this

{        
    "schedules": ["adelev@contoso.onmicrosoft.com", "meganb@contoso.onmicrosoft.com"],
    "startTime": {
        "dateTime": "2019-03-15T09:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "endTime": {
        "dateTime": "2019-03-15T18:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "availabilityViewInterval": "60"
}

I place all of the rooms in the office in the schedules list, and then can see their availabilities in the response based on the availability view.

"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.scheduleInformation)",
    "value": [
        {
            "scheduleId": "adelev@contoso.onmicrosoft.com",
            "availabilityView": "000220000",
            "scheduleItems": [
                {
                    "isPrivate": false,
                    "status": "busy",
                    "subject": "Let's go for lunch",
                    "location": "Harry's Bar",
                    "start": {
                        "dateTime": "2019-03-15T12:00:00.0000000",
                        "timeZone": "Pacific Standard Time"
                    },
                    "end": {
                        "dateTime": "2019-03-15T14:00:00.0000000",
                        "timeZone": "Pacific Standard Time"
                    }
                }
            ],
            "workingHours": {
                "daysOfWeek": [
                    "monday",
                    "tuesday",
                    "wednesday",
                    "thursday",
                    "friday"
                ],
                "startTime": "08:00:00.0000000",
                "endTime": "17:00:00.0000000",
                "timeZone": {
                    "name": "Pacific Standard Time"
                }
            }
        },

However, I don't need any of the other information provided in the response. I only want to see the scheduleId and the availabilityView, because the response takes forever to load with many rooms in the schedules request.

I've been looking at the available ways to filter a response through parameters in the POST request at: https://docs.microsoft.com/en-us/graph/query-parameters . However, any of the filters I seem to apply to my address do not seem to have any affect on the response.

I've tried

https://graph.microsoft.com/v1.0/me/calendar/getschedule?$select=availabilityView

for the request and other similar variants without any success. They all return the full JSON response.

It is a OData protocol limitation. Querying Data is only possible on GET requests as documented here .
Besides asking for less rooms to begin with. a shorter period or a bigger interval, I don't think there a way to get less data today.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM