TFS Rest API; Update failing

  • Thread starter Thread starter Divya Varma
  • Start date Start date
D

Divya Varma

Guest
I have a script that updates a TFS build definition. When I am using SYSTEM_ACCESSTOKEN for authentication, it fails with the error

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"TF215106: Access denied. Project Collection Build
Service (<collection name>) needs Edit build definition permissions for build definition <Build ID> in team project


What permissions am I missing?

I made sure the service account that TFS is running under has permissions to edit the build definition.

Here is the code

$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"

$Updatedefinition = Invoke-RestMethod -uri $url -Method PUT -Body ($definitionJSON) -ContentType "application/json" -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }

Continue reading...
 
Back
Top