401.1 Permission error with on-premises TFS when accessing the API with a PAT
Background If you are creating VSTS build extensions you will need to get the build or release’s PAT token if you wish to call the VSTS REST API. This is done using a call like this (Node) import tl = require('vsts-task-lib/task'); var auth = tl.getEndpointAuthorization('SYSTEMVSSCONNECTION', false); if (auth.scheme === 'OAuth') { var token = auth.parameters\['AccessToken'\]; or (PowerShell) $vssEndPoint = Get-ServiceEndPoint -Name "SystemVssConnection" -Context $distributedTaskContext $personalAccessToken = $vssEndpoint.Authorization.Parameters.AccessToken You pop the resultant PAT into the headers of your REST web request and you are away and running....