问题
I have an Area that I've created using the SDK, and I have a Team. How can I, using the SDK, add that Area to the Team?
It's simple enough to do so with an Iteration, using the WorkHttpClient.PostTeamIterationAsync()
method (code below), but there's no corresponding method available to do the same with an Area.
I looked briefly at the method's source code, but it contains a GUID
indicating the target location (Iterations). If I can avoid it, I'd rather not risk getting down to that level by modifying it for my own use for Areas. Surely there's a higher-level way to do this.
According to this Q&A, it can be done via the REST API—but I'm using the SDK. Then there's this, but the answers there appear to be using an outdated version. The classes referenced aren't available in the latest stable version.
Can this be done?
Private Function AddSprintToTeam(Sprint As Classifications.Iteration) As TeamSettingsIteration
Dim oContext As TeamContext
Dim oSprint As TeamSettingsIteration
Dim oTeams As List(Of WebApiTeam)
Dim oTeam As WebApiTeam
Using oTeamClient As TeamHttpClient = Utils.Connection.GetClient(Of TeamHttpClient)
Using oWorkClient As WorkHttpClient = Utils.Connection.GetClient(Of WorkHttpClient)
oTeams = oTeamClient.GetTeamsAsync(ProjectName).Result
oTeam = oTeams.Single(Function(Team) Team.Name.StartsWith(ProjectName))
oContext = New TeamContext(ProjectName, oTeam.Name)
oSprint = New TeamSettingsIteration With {.Id = Sprint.Identifier}
oSprint = oWorkClient.PostTeamIterationAsync(oSprint, oContext).Result
End Using
End Using
Return oSprint
End Function
回答1:
You can use UpdateTeamFieldValuesAsync()
Method to add an existing Area to an existing Team. Check here.
See the related rest api here. You can check out the example given in the Rest api document.
来源:https://stackoverflow.com/questions/65472137/how-to-add-an-existing-area-to-an-existing-team