Search code examples
c#-4.0microsoft-graph-api

Is there a way to list all rooms in a roomlist with C# Microsoft.Graph library?


I am creating backend service that is supposed to subscribe to Microsoft Graph API and receive notification whenever there is a new meeting scheduled in one of our meeting rooms.

I am getting all roomLists in our tenant like this: await graphServiceClient.Places.GraphRoomList.GetAsync()

Then I wanted to get all the rooms in the specific roomList. However I cant figure out a way to do that with Microsoft.Graph (Nugget package v. 5.22.0).

http call should be: GET https://graph.microsoft.com/v1.0/places/roomEmailAddress/microsoft.graph.roomlist/rooms

I tried creating request this way: await graphServiceClient.Places[roomList.EmailAddress].GraphRoomList.GetAsync()

but the response object has the "rooms" property null and I can see that graph API processed the request like this: https://graph.microsoft.com/v1.0/$metadata#places/microsoft.graph.roomList/('roomEmailAddress') but the correct call should look like this: https://graph.microsoft.com/v1.0/$metadata#places('roomEmailAddress')/microsoft.graph.roomList/rooms

both calls are valid but only the second one lists the rooms. I verified that through Postman

In the microsoft documentation (https://learn.microsoft.com/en-us/graph/api/place-list?view=graph-rest-1.0&tabs=csharp) they dont provide C# example, only Java.

Is it not possible to do this call in C#? Is there alternative way of getting all of the rooms in a specific roomList?


Solution

  • You are right, the is no way to convert https://graph.microsoft.com/v1.0/places/roomEmailAddress/microsoft.graph.roomlist/rooms to C#.

    As a workaround, you can try expand rooms on roomlist

    https://graph.microsoft.com/v1.0/places/roomEmailAddress/microsoft.graph.roomlist?$expand=rooms
    

    C# code:

    var roomlist = await m_client.Places["roomEmailAddress"].GraphRoomList.GetAsync((requestConfiguration) =>
    {
        requestConfiguration.QueryParameters.Expand = new string[] { "rooms" };
    });
    var rooms = roomlist.Rooms;