-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to get ID of a newly created Teams team #716
Comments
Hi @HorizonNet , as you correctly mentioned, this is a long running api that does not respond immediately with the team id. We do have an issue tracking design and development to support such API's. |
@rkodev Thanks for the hint. Can you please share the example in docs link again? This seems to be typical ATP Safelink. |
@HorizonNet I've updated the correct link. Here is sample code to get the // introspect headers
headerOptions := nethttplibrary.NewHeadersInspectionOptions()
headerOptions.InspectResponseHeaders = true
requestConfig := &teams.TeamsRequestBuilderPostRequestConfiguration{
Options: []abstractions.RequestOption{
headerOptions,
},
}
teams, err := client.Teams().Post(context.Background(), newTeam, requestConfig)
// get the location from header value
locations := headerOptions.GetResponseHeaders().Get("Location") |
@rkodev Thanks a lot! I'm going to give it a try soon. Am I getting it right that the Location and Content-Location contains the ID, which will be assigned for the team? If that's the case I could use a simple polling on |
@HorizonNet Welcome. That should be the case. Once you try the solution you can update the issue. |
@rkodev I gave it a try and the response headers are empty. I'm using the following snippet after the one from my initial post. headerOptions := nethttplibrary.NewHeadersInspectionOptions()
headerOptions.InspectResponseHeaders = true
requestConfig := &teams.TeamsRequestBuilderPostRequestConfiguration{
Options: []abstractions.RequestOption{
headerOptions,
},
}
_, err = client.Teams().Post(context.Background(), newTeam, requestConfig)
if err != nil {
fmt.Println(err)
}
locations := headerOptions.GetResponseHeaders().Get("Location") I'm working against a M365 Developer tenant. Based on other working things I would assume that there should not be a difference to a regular tenant. Is there anything missing? |
@HorizonNet Can you check the value of |
@rkodev I also tried this one and it's empty as well. |
@HorizonNet could you kindly share the response headers you get when using graph explorer |
@rkodev When using Graph Explorer on the same tenant the newTeam := graphmodels.NewTeam()
displayName := "Test team"
newTeam.SetDisplayName(&displayName)
newTeam.SetAdditionalData(map[string]interface{}{
"template@odata.bind": "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{}{
"user@odata.bind": "https://graph.microsoft.com/v1.0/users('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')",
})
membersToAdd := []graphmodels.ConversationMemberable{
conversationMember,
}
newTeam.SetMembers(membersToAdd)
headerOptions := nethttplibrary.NewHeadersInspectionOptions()
headerOptions.InspectResponseHeaders = true
requestConfig := &teams.TeamsRequestBuilderPostRequestConfiguration{
Options: []abstractions.RequestOption{
headerOptions,
},
}
_, err = client.Teams().Post(context.Background(), newTeam, requestConfig)
if err != nil {
fmt.Println(err)
}
locations := headerOptions.GetResponseHeaders().Get("location") |
Hi @HorizonNet, looking at your code again, this should be working. Could you attempt to print all the headers using this snippet for _, key := range headerOptions.GetResponseHeaders().ListKeys() {
fmt.Println(key, headerOptions.GetResponseHeaders().Get(key))
} |
@rkodev There are no headers, resulting into |
I'm following the documentation to create a team in Teams by using the following code:
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.
The text was updated successfully, but these errors were encountered: