22 C
Bangalore
October 14, 2018
Untitled

CONNECTING VSTS USING REST API IN POWERSHELL

CONNECTING VSTS USING REST API IN POWERSHELL

Generate a API PAT token that can be used for connecting to VSTS using REST API 

Go to security page of VSTS dashboard of individual user and generate an Personal Access Token token.

Keep in mind PAT is generated once and cannot be generated the same token again.

Lets connect VSTS and list down all the build definitions using a REST call.

$TokenAccess = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$URI = "https://xxxxx.visualstudio.com/MyFirstProject/_apis/build/definitions?api-version=2.0"

Invoke-RestMethod -Method Get -Uri $URI -Headers @{Authorization = ‘Basic ‘ + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(“:$($TokenAccess)”))      

Related posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.