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

问题描述 投票:0回答:1

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

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

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

如你所见,我需要提供一个teamSettingsPatch对象和一个teamContext对象。我已经找到teamContext并在其他调用中成功使用它,但我似乎无法提供导致API返回成功响应的teamSettingsPatch对象。到目前为止,我得到了400 Bad Request和一个空对象作为回报({ })我所尝试的一切。 (编辑:这个空对象和错误的请求是由于我自己的包装器代码中的一个错误,你在TeamSettingsUpdate中真正得到的不成功的是一个返回的设置对象,其值没有随着你的改变而改变期望)。

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错误。

javascript node.js azure-devops backlog
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
          ]
    }
© www.soinside.com 2019 - 2024. All rights reserved.