尝试更新团队字段值时出错 [英] Errors when attempting to update team field values

查看:66
本文介绍了尝试更新团队字段值时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Client SDK将现有区域添加到现有团队时,出现多个错误.这是我的代码:

I'm getting any of multiple errors when I try to use the Client SDK to add an existing Area to an existing Team. Here's my code:

Using oTeamClient As TeamHttpClient = Utils.Connection.GetClient(Of TeamHttpClient)
  Using oWorkClient As WorkHttpClient = Utils.Connection.GetClient(Of WorkHttpClient)
    oValue = New TeamFieldValue With {.Value = Area.Path, .IncludeChildren = False}
    oTeams = oTeamClient.GetTeamsAsync(ProjectName).Result
    oTeam = oTeams.Single(Function(Team) Team.Name.StartsWith(ProjectName))
    oPatch = New TeamFieldValuesPatch With {.Values = {oValue}, .DefaultValue = $"{ProjectName}\{Area.Path}"}
    oContext = New TeamContext(ProjectName, oTeam.Name)

    Return oWorkClient.UpdateTeamFieldValuesAsync(oPatch, oContext).Result
  End Using
End Using

问题是我不知道将什么用于 TeamFieldValuesPatch.DefaultValue .

The problem is that I don't know what to use for TeamFieldValuesPatch.DefaultValue.

这是我尝试过的内容,以及每次尝试相应的错误消息:

Here's what I've tried and the corresponding error message for each attempt:

  • 一无所有:"DefaultValue"
  • 空字符串:"VssServiceException:默认团队字段值必须是该团队允许的团队字段值之一."
  • 项目名称:"VssServiceException:默认团队字段值必须是该团队允许的团队字段值之一."
  • 区域路径:"VssServiceException:TF400499:您尚未设置团队字段."
  • 项目名称+区域路径:"VssServiceException:默认团队字段值必须是该团队允许的团队字段值之一."

不幸的是,

Unfortunately, the documentation provides no explanation of the validation rules for this property, nor any guidance on what value we should use. It seems to indicate Project Name + Area Path, but as we can see above that doesn't work.

,但与文档中的(模糊)提示冲突.有

There's this, but it conflicts with the (obscure) hint in the documentation. There's this, but I've verified that the Area exists before the update is attempted.

该属性应使用什么值?

推荐答案

上述错误默认团队字段值必须是该团队允许的团队字段值之一您在 TeamFieldValuesPatch.DefaultValue 属性中定义的区域路径也必须包含在 TeamFieldValuesPatch.Values 属性中.

The above error The default team field value must be one of this team's allowed team field values means the area path you defined in the TeamFieldValuesPatch.DefaultValue property must be included in the TeamFieldValuesPatch.Values property too.

如果在 Values 中找不到为 DefaultValue 定义的区域路径.上面的错误将被抛出.参见下面的c#

If the area path defined for DefaultValue cannot be found in the Values. Above error will be thrown out. See below example in c#

 VssConnection _connection = new VssConnection(accountUri, new VssBasicCredential(string.Empty, personalAccessToken));

 WorkHttpClient workClient = _connection.GetClient<WorkHttpClient>();
 TeamFieldValuesPatch patch = new TeamFieldValuesPatch();
 patch.DefaultValue = "Project\\DefaultAreaPath";
            
 List<TeamFieldValue> values = new List<TeamFieldValue> { 
   #defaultValue must be included in the values 
   new TeamFieldValue { Value = "Project\\DefaultAreaPath", IncludeChildren = false },
   new TeamFieldValue { Value = "Project\\OtherAreaPath", IncludeChildren = false }
 };
            
 patch.Values = values;
 TeamContext team = new TeamContext("Project", "Team");

 var res = workClient.UpdateTeamFieldValuesAsync(patch, team).Result;

这篇关于尝试更新团队字段值时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆