-
Notifications
You must be signed in to change notification settings - Fork 249
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
Teams AddAsync/PostAsync is totally and utterly broken #1366
Comments
Just wait until your call to Teams[].Operations[] returns a 404. You are left with nothing... The workaround is to query Teams using the displayName and hope that your new team name didn't get adjusted because of duplicates... |
No updates on this issue? |
Hi @andrueastman . Can you please take a look at this? |
The following call results to the equivalent of the documented api call here. As the API returns no response body the returned value is null. var newteam = await GraphClient.Teams.Request().AddAsync(team, cancellationToken: CancellationToken); Due to the metadata used for SDK generation, the correct return type for this and other related functions should be resolved as we move to accurate description using OpenAPI in the next major version of the SDK. The Core library also provides the // create the team
var team = new Team
{
DisplayName = "My Sample Team",
Description = "My Sample Team’s Description",
AdditionalData = new Dictionary<string, object>()
{
{"[email protected]", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
}
};
var teamsCreateReponse = await graphClient.Teams
.Request()
.AddResponseAsync(team);
var locationHeader = teamsCreateReponse.HttpHeaders.Location;
if (locationHeader != null)
{
if (!locationHeader.IsAbsoluteUri)
locationHeader = new Uri(graphClient.BaseUrl + locationHeader.OriginalString);
// create the monitor
var asyncMonitor = new AsyncMonitor<Team>(graphClient, locationHeader.AbsoluteUri);
IProgress<AsyncOperationStatus> progress = new Progress<AsyncOperationStatus>(operationStatus =>
{
Console.WriteLine($"Operation status is {operationStatus.Status} complete");
});
var createdTeam = await asyncMonitor.PollForOperationCompletionAsync(progress, CancellationToken.None);
Console.WriteLine($"Team created with id: {createdTeam.Id}");
} However, on testing, it seems the teams API returns 200 response instead of the expected 202 response in the AsyncMonitor at the link below to result in the monitor exiting early for the teams scenario. To resolve this, we would need to update the monitor code to also allow for scenarios where the monitor endpoint returns 200 response status code as well. |
A new timing bug seems to have entered the Teams Bot world. |
With regards to the AsyncMonitor, then it is not really compatible with Teams at all
|
Describe the bug
A reasonable person might think that this was the correct usage of the API:
var newteam = await GraphClient.Teams.Request().AddAsync(team, cancellationToken: CancellationToken);
but noooo, that just returns null.
Another reasonable person might see that there is a AddResponseAsync and try:
bot noooooo, that also just returns null. (FYI, there is no overload of GetResponseObjectAsync that takes CancellationToken, which is a bug in itself)
A totally fucking idiot might design the API to actually be called in this way:
And why is the last outcome of an successful operation
TeamsAsyncOperationStatus.NotStarted
?!?!?!?!?Expected behavior
var newteam = await GraphClient.Teams.Request().AddAsync(team, cancellationToken: CancellationToken);
works... or atleast returns an "TeamsCreationAsyncResult" that can be used to query the further result.
Client version
4.29
The text was updated successfully, but these errors were encountered: