0

I'm trying to consume the vso-node-api, and I want to automatically set the backlog iteration for a team that I've created fresh using the API previously.

I'm having some trouble using the updateTeamSettings in the WorkApi:

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

As you see here, I need to provide a teamSettingsPatch object and a teamContext object. I've already figured out teamContext and have used it successfully in other calls, but I can't seem to provide a teamSettingsPatch object that causes the API to return a successful response. So far I get 400 Bad Request and an empty object in return ({ }) for everything I've tried. (Edit: This empty object and bad request was due to a bug in my own wrapper code, what you'll really get with a TeamSettingsUpdate that isn't successful is a settings object returned with values that weren't changed as you'd expect).

WorkInterfaces.ts indicates that I need to provide an object like this:

/**
 * 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[];
}

I've tried to provide an object like this. In my previous experiences, the vso-node-api wants all properties to be defined whether or not their values are filled with anything, so first I tried this:

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

However, I still get the Bad Request message when I try this.

I've also tried to use the getTeamSettings call to attempt to figure out what the API wants for the TeamSettingsPatch object, and I've tried to fill in everything possible including values that are already being shown to me from getTeamSettings. Note that the zeroed GUID is exactly what getTeamSettings gives me:

{
    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
    ]
}

I'm at a bit of a loss. Is it not working because I'm providing a bad object in my request, or is it not working because this API functionality isn't working yet? The response from the API isn't providing any hints, just an empty object and a 400 error.

alexk
  • 1,254
  • 1
  • 11
  • 16

1 Answers1

1

First, it doesn’t work with name of backlogIteration, required the ID.

Secondly, the value of backlogIteration is incorrect , I can get the correct value by calling getTeamSettings function (but you can’t), you can update the vso-node-api to latest version (e.g. 6.2.8-preview) and check the result, you also can call Get a team’s settings REST api manually to get the value.

The teamSettingPatch of mine:

{
        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
          ]
    }
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Good thought on checking for the latest API version, especially since it's in preview. I'll try out your suggestions in this answer tomorrow, thanks again for helping out with this API! – alexk Jan 01 '18 at 18:02
  • Thoughts for anyone else with this problem: Ensure all your input JSON objects have the correct capitalization (like the teamContext or teamSettingsPatch). I wasted a long time with teamId incorrectly written as teamID - and the vso-node-api will not indicate failure in that scenario. – alexk Jan 03 '18 at 21:25