Having trouble converting to Microsoft.Graph 5.0.0 and Microsoft.Graph.Core 3.0.0

Giuseppe Carafa 96 Reputation points
2023-03-06T17:54:34.3166667+00:00

I'm trying to update NuGet packages for Microsoft.Graph from 4.54.0 to 5.0.0 and Microsoft.Graph.Core from 2.0.15 to 3.0.0

Most of the VB.NET project, .NET Framework 4.8, I inherited has no problem with this change but there are two pieces of code that throw errors:

(I couldn't pick VB.NET as the development language so I picked the closest alternative, ASP.NET even though this is a desktop application)


            '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)

Looking at the code I think that the group variable was originally defined as a Microsoft.Graph.Group and the graphClient object as a Microsoft.Graph.GraphServiceClient when using the NuGet packages 4.54.0 and 2.0.15 respectively.

Likewise, trying to define a team variable fails

            'Create a team for the group.
            If (responseRef.StatusCode = HttpStatusCode.NoContent) Then
                Dim team = New Team With {
                   .GuestSettings = New TeamGuestSettings With {
                   .AllowCreateUpdateChannels = False,
                   .AllowDeleteChannels = False,
                   .ODataType = Nothing
                    },
                .ODataType = Nothing
                }

                Dim response = Nothing
                Try
                    response = Await graphClient.Groups(data.Id).Team.Request().PutAsync(team)
                Catch ex As Exception
                    'Creating teams API failed sometimes, unfortunately, await method can't be used in vb.net in catch or finally statement, its only available in c#, 
                    'so If the response Is nothing, trying to call the api once again.
                End Try
'etcetera.....

With the previous NuGet packages the variable team was defined as a Microsoft.Graph.Team

Can somebody give me a simple steer on how to change these code snippets so that they will work again with the latest NuGet packages 5.0.0 and 3.0.0 ? I have looked at what documentation I can find but I'm very unfamiliar with these packages and I find it nearly impenetrable, sorry.

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,445 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
{count} votes