In TFS (or ADO) is there an API call to link a Team to an Area Path?

别等时光非礼了梦想. 提交于 2021-02-11 12:25:53

问题


We're automating our TFS Team/Board creation and found that there is an API to create a Team and an API to create an Area Path, but not one to link the two. Basically we're looking for something that acts as the ‘Create an area path with the name of the team.’ check box in the attached picture.Screenshot Here's the code for our Team post:

$azdoURI = https://prd-ourCompanyName/tfs/ourOrg/_apis/projects/ourProject/teams?api-version=5.0"
$requestBody = @{ name = "$boardName" }
$jsonRequestBody = $requestBody | ConvertTo-Json -Compress

$response = (Invoke-WebRequest -Method Post -Uri $azdoURI -Body $jsonRequestBody -Content 'application/json' -Credential $credential -UseBasicParsing)

回答1:


Adding an iteration to a team is done through the /_apis/work/teamsettings/iterations API.

Request:

POST https://dev.azure.com/fabrikam/Fabrikam-Fiber/_apis/work/teamsettings/iterations?api-version=5.1
"{\"id\":\"a589a806-bf11-4d4f-a031-c19813331553\"}"

Response:

{
  "id": "a589a806-bf11-4d4f-a031-c19813331553",
  "name": "Sprint 2",
  "path": "Fabrikam-Fiber\\Release 1\\Sprint 2",
  "attributes": {
    "startDate": null,
    "finishDate": null
  }
}

To set area paths use the /_apis/work/teamsettings/teamfieldvalues:

Request:

PATCH https://dev.azure.com/fabrikam/Fabrikam-Fiber/_apis/work/teamsettings/teamfieldvalues?api-version=5.1
{
  "defaultValue": "Fabrikam-Fiber\\Auto",
  "values": [
    {
      "value": "Fabrikam-Fiber\\Auto",
      "includeChildren": true
    },
    {
      "value": "Fabrikam-Fiber\\Fiber",
      "includeChildren": false
    },
    {
      "value": "Fabrikam-Fiber\\Optics",
      "includeChildren": false
    }
  ]
}

Response:

{
  "field": {
    "referenceName": "System.AreaPath",
    "url": "https://dev.azure.com/fabrikam/_apis/wit/fields/System.AreaPath"
  },
  "defaultValue": "Fabrikam-Fiber\\Auto",
  "values": [
    {
      "value": "Fabrikam-Fiber\\Auto",
      "includeChildren": true
    },
    {
      "value": "Fabrikam-Fiber\\Fiber",
      "includeChildren": false
    },
    {
      "value": "Fabrikam-Fiber\\Optics",
      "includeChildren": false
    }
  ]
}

See also:

  • TeamFieldvales
  • Iterations



回答2:


Basically we're looking for something that acts as the ‘Create an area path with the name of the team.’ check box in the attached picture.

If I understand you well, you're trying to create a new Team Project in which there's one default Area path. (Of course you also want their names should be the same)

For TFS2018U2, try:

POST https://{instance}/{collection}/_apis/projects?api-version=4.1

For Azure Devops Server 2019, try:

POST https://{instance}/{collection}/_apis/projects?api-version=5.0

You can find more details from my another post here. After my check, this api will automatically define the default area path with same name like Team project's:



来源:https://stackoverflow.com/questions/61102413/in-tfs-or-ado-is-there-an-api-call-to-link-a-team-to-an-area-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!