Where can I find System.TeamProjectId for a project in Azure Devops

Viewed 11450

I need this Id upfront but I can't seem to find it anywhere online?
The documentation only refers to it as a system variable.

Context: I have multiple projects and I want to identify a project during CI so it can run a powershell script hosted in another repository.

2 Answers

You can get the all team projects id with REST Api:

 https://dev.azure.com/{organization}/_apis/projects?api-version=5.0-preview.3

Results:

 {
  "count": 3,
  "value": [
    {
      "id": "eb6e4656-77fc-42a1-9181-4c6d8e9da5d1",
      "name": "Fabrikam-Fiber-TFVC",
      "description": "Team Foundation Version Control projects.",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/eb6e4656-77fc-42a1-9181-4c6d8e9da5d1",
      "state": "wellFormed"
    },
    {
      "id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
      "name": "Fabrikam-Fiber-Git",
      "description": "Git projects",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
      "state": "wellFormed"
    },
    {
      "id": "281f9a5b-af0d-49b4-a1df-fe6f5e5f84d0",
      "name": "TestGit",
      "url": "https://dev.azure.com/fabrikam/_apis/projects/281f9a5b-af0d-49b4-a1df-fe6f5e5f84d0",
      "state": "wellFormed"
    }
  ]
}

You don't even need use Postman or create Http request, just enter the API url above in the browser.

You can examine the HTML in the UI of the dashboard on your organisation projects page:

enter image description here

Related