Search code examples
c#vb.netmicrosoft-graph-apinuget-packagemicrosoft-graph-teams

Running into a few problems after updating Microsoft.Graph and Microsoft.Graph.Core - looking to replace these code snippets


We have created software to integrate with Microsoft Teams, using the Microsoft.Graph packages from NuGet.

Up until recently these were working fine even while Microsoft regularly updated its NuGet packages. We had no problem with Microsoft.Graph 4.54.0 and Microsoft.Graph.Core 2.0.15

Today I discovered that Microsoft have now released NuGet Packages Microsoft.Graph 5.0.0 and Microsoft.Graph.Core 3.0.0 so I tried updating these packages but now they are throwing errors when I tried to rebuild the project. Please forgive the use of VB.NET as I'm not responsible for the language in which this was written...

        'Create a group in MS Teams
        Dim group = New Group With {
            .Description = teamDescription,
            .DisplayName = teamName,
            .GroupTypes = New List(Of String)() From {
                "Unified"
            },
            .MailEnabled = True,
            .MailNickname = LibraryKey,
            .SecurityEnabled = False,
            .Visibility = If(IsPrivateTeam, "Private", "Public")
        }
        Dim data = Await graphClient.Groups.Request().AddAsync(group)

The snippet of code above leads to two errors:

  1. Type 'Group' is not defined and
  2. 'Request' is not a member of 'GroupsRequestBuilder'

The other problematic code snippet is:

            Dim team = New Team With {
               .GuestSettings = New TeamGuestSettings With {
               .AllowCreateUpdateChannels = False,
               .AllowDeleteChannels = False,
               .ODataType = Nothing
                },
            .ODataType = Nothing
            }

Which leads to a very similar error:

Type 'Team' is not defined.

I am hoping that these can easily be replaced with variations that are compatible with Microsoft.Graph 5.0.0 c.q. Microsoft.Graph.Core 3.0.0 ? I'll be happy with suggestions in C# which I will gladly convert to VB.NET myself


Solution

  • I'm using GraphAPI package at 5.0, and groups/Teams is all I'm coding for, this works for me, in current Graph client-config: (with similar var names/syntax)

     Dim group = New Group With {
          .Description = teamDescription,
          .DisplayName = teamName,
          .GroupTypes = New List(Of String)() From {
              "Unified"
           },
           .MailEnabled = True,
           .MailNickname = LibraryKey,
           .SecurityEnabled = False,
           .Visibility = If(IsPrivateTeam, "Private", "Public")
         }
     
        Dim data = Await graphClient.Groups.PostAsync(group)
    

    sorry this is coming 2-months later