ʃʈɑɲ
ʃʈɑɲ

Reputation: 2684

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

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.

Upvotes: 30

Views: 31829

Answers (3)

RSW
RSW

Reputation: 1376

As outlined here on azure devops documentation, you can curl below url:

curl "https://dev.azure.com/_apis/resourceAreas/79134C72-4A58-4B42-976C-04E7115F32BF?accountName=<ORG_NAME_HERE>&api-version=5.0-preview.1"

# Output: 
{"id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","name":"core","locationUrl":"https://dev.azure.com/ORG_NAME_HERE/"}

With just the organization's name or ID, you can get its base URL using the global Resource Areas REST API (https://dev.azure.com/_apis/resourceAreas). This API doesn't require authentication. It also provides information about the location (URL) of the organization and the base URL for REST APIs, which can live on different domains.

Upvotes: 0

Andy Hoyle
Andy Hoyle

Reputation: 846

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

enter image description here

Upvotes: 26

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

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.

Upvotes: 55

Related Questions