1
votes

I have been successfully able to use Release Definition API on our TFS 2015 Update 3 on prem instance using API Version "3.0-preview.1". But ever since I started testing this on VSTS, I am continuously getting a 404 error stating

Page not found And a long block of HTML.

I am using PowerShell to call the API. And I am creating the API request as mentioned in the documentation using Personal Access Token and Alternate credential method.

https://fabfiber.vsrm.visualstudio.com/DefaultCollection/ff213d65-d61d-447c-b39d-d16f21b18364/_apis/release/definitions?api-version=3.0-preview.1

Can someone let me know if I am missing something.

2
which URL are you actually using? You should replace 'fabfiber' with your VSTS account name, and the GUID with your own Team Project ID or NameLuca Cappa
I have my own URL created in a similar manner stated above i.e. https://<myinstance.visualstudio.com>/DefaultCollection/<Project ID>/_apis/release/definitions?api-version=3.0-preview.1Ankush Gupta
then you are missing .vsrm. from the url, like <myinstance>.vsrm.visualstudio.com , as documentedLuca Cappa
Thanks.. I got it. But I wonder why they have a different url for Release definition.Ankush Gupta

2 Answers

3
votes

Try this code:

$vstsAccount = "[your vsts name]"
$user = "test"
$accessToken="[personal access token]"
$teamProject="[team project name]"
Function QueryWorkItem{
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$accessToken)))
 $uri="https://$vstsAccount.vsrm.visualstudio.com/defaultcollection/$teamProject/_apis/release/definitions?api-version=3.0-preview.1"
$result = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}