AAD Object ID of a rooms on running https://graph.microsoft.com/v1.0/places/microsoft.graph.room

Viewed 48

I have the following code to get rooms from graph:

            var roomUrl = graphClient.Places.AppendSegmentToRequestUrl("microsoft.graph.room");
            var response= await new GraphServicePlacesCollectionRequest(roomUrl, graphClient, null).GetAsync();
            if (response.CurrentPage.Count > 0)
            {
                foreach (var room in response.CurrentPage)
                {  
                    Console.WriteLine(room.Id);
                }
            }             

room.Id represents RoomId which is different from AAD object Id of the room.

Is there a way to get object Id of the room instead of room Id in the response?

1 Answers

You will need to call another endpoint.

Take an emailAddress of the room and call Users endpoint. Users endpoint doesn't return only users but also rooms.

var roomMail = room.EmailAddress;
var roomUser = await graphClient.Users[roomMail].Request().GetAsync();
// read AAD object id
var aadObjectId = roomUser.Id;
Related