msgraph-sdk-go
msgraph-sdk-go copied to clipboard
Unable to get ID of a newly created Teams team
trafficstars
I'm following the documentation to create a team in Teams by using the following code:
newTeam := graphmodels.NewTeam()
displayName := "Test team"
newTeam.SetDisplayName(&displayName)
newTeam.SetAdditionalData(map[string]interface{}{
"[email protected]": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
})
// Set the owner of the team
conversationMember := graphmodels.NewAadUserConversationMember()
roles := []string{"owner"}
conversationMember.SetRoles(roles)
conversationMember.SetAdditionalData(map[string]interface{}{
"[email protected]": "https://graph.microsoft.com/v1.0/users('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')",
})
membersToAdd := []graphmodels.ConversationMemberable{
conversationMember,
}
newTeam.SetMembers(membersToAdd)
teams, err := client.Teams().Post(context.Background(), newTeam, nil)
if err != nil {
fmt.Println(err)
}
fmt.Println(teams.GetId())
In the TAC I can see that the team was created successfully, but when trying to get the ID of the newly created team at the end (for further processing) I receive an invalid memory address or nil pointer dereference.
Based on the documentation I would assume that's due to the expected HTTP 202 received from the POST and that the creation of the team takes a little bit in the background. Am I missing something? I wasn't able to find something related in the documentation pointing me to a solution.