首页 文章

如何使用VSTS Node API设置积压迭代?

提问于
浏览
0

我正在尝试使用vso-node-api,我想自动设置我之前使用API创建的团队的积压迭代 .

我在使用_2593401中的 updateTeamSettings 时遇到了一些麻烦:

updateTeamSettings(teamSettingsPatch: WorkInterfaces.TeamSettingsPatch, teamContext: TfsCoreInterfaces.TeamContext): Promise<WorkInterfaces.TeamSetting>;

如您所见,我需要提供 teamSettingsPatch 对象和 teamContext 对象 . 我已经找到 teamContext 并在其他调用中成功使用它,但我似乎无法提供导致API返回成功响应的 teamSettingsPatch 对象 . 到目前为止,我得到 400 Bad Request 和一个空对象作为回报( { } )我已经尝试过的一切 . ( Edit: 这个空对象和错误的请求是由于我自己的包装器代码中的一个错误,你成功的是一个设置对象返回的值不是't changed as you'期望的) .

WorkInterfaces.ts表示我需要提供这样的对象:

/**
 * Data contract for what we expect to receive when PATCH
 */
export interface TeamSettingsPatch {
    backlogIteration: string;
    backlogVisibilities: { [key: string] : boolean; };
    bugsBehavior: BugsBehavior;
    defaultIteration: string;
    defaultIterationMacro: string;
    workingDays: SystemInterfaces.DayOfWeek[];
}

我试图提供这样的对象 . 在我以前的经验中, vso-node-api 想要定义所有属性,无论它们的值是否被任何东西填充,所以首先我尝试了这个:

{
    backlogIteration: 'Backlog-Iteration-Name',
    backlogVisibilities: { },
    bugsBehavior: null,
    defaultIteration: null,
    defaultIterationMacro: '@currentIteration',
    workingDays: [
        1,
        2,
        3,
        4,
        5
    ]
}

但是,当我尝试这个时,我仍然收到Bad Request消息 .

我还尝试使用 getTeamSettings 调用来尝试找出API对 TeamSettingsPatch 对象的要求,并且我已经尝试填写所有可能的内容,包括已经从 getTeamSettings 向我显示的值 . 请注意,归零的GUID正是 getTeamSettings 给我的:

{
    backlogIteration: {
      id: '00000000-0000-0000-0000-000000000000'
    },
    backlogVisibilities: {
      'Custom.1f38c336-f308-41a6-adaa-eb78c0f72dd5': false,
      'Microsoft.FeatureCategory': true,
      'Microsoft.EpicCategory': false,
      'Microsoft.RequirementCategory': true
    },
    bugsBehavior: 2,
    defaultIteration: null,
    defaultIterationMacro: '@currentIteration',
    workingDays: [
      1,
      2,
      3,
      4,
      5
    ]
}

我有点失落 . 它不起作用,因为我在我的请求中提供了一个坏对象,或者它是否工作,因为这个API功能还没有工作呢? API的响应不提供任何提示,只提供空对象和400错误 .

1 回答

  • 1

    首先,它不适用于backlogIteration的名称,需要ID .

    其次,backlogIteration的值不正确,我可以通过调用getTeamSettings函数得到正确的值(但你不能),你可以将vso-node-api更新到最新版本(例如6.2.8-preview)并检查结果,您也可以手动调用Get a team’s settings REST api来获取值 .

    我的团队设置补丁:

    {
            backlogIteration: "d3f3738d-d874-46a9-941d-54a5ca0f6f2d",
            backlogVisibilities:{
                "Microsoft.EpicCategory": false,
                "Microsoft.FeatureCategory": true,
             "Microsoft.RequirementCategory": true
            },
            bugsBehavior: 2,
            defaultIteration: null,
            defaultIterationMacro: null,
            workingDays:[
                1,
                2,
                3,
                4
              ]
        }
    

相关问题