1
votes

I want to be able to get information about the latest pipeline builds using the Azure DevOps REST API. I'm using Azure DevOps Server 2020 with the January 12 update.

This is the API endpoint I'm using: https://[organization url]/[project name]/_apis/build/latest/succeeded?api-version=6.0-preview.1

I get this error after making the GET request:

{"$id":"1","innerException":null,"message":"Build pipeline succeeded was not
     | found.","typeName":"Microsoft.TeamFoundation.Build.WebApi.DefinitionNotFoundException,
     | Microsoft.TeamFoundation.Build2.WebApi","typeKey":"DefinitionNotFoundException","errorCode":0,"eventId":3000}

I've also tried these variations of the API endpoint:

  • https://[organization url]/[project name]/_apis/build/latest/BuildResult?api-version=6.0-preview.1

  • https://[organization url]/[project name]/_apis/build/latest/BuildResult=succeeded?api-version=6.0-preview.1

I end up getting the same type of error. I know the base API url works because I'm able to get a valid response back using the Get Commits endpoint.

How do I get the url to work?

UPDATE: Using @GChamon answer as a guide I got the latest successful builds.

This is the url that worked for me:

http://[organization url]/[project name]/_apis/build/builds?resultFilter=succeeded&api-version=6.0

Interestingly when I tried to only use `.../build/builds' without any optional parameters it didn't return any results. When I added an optional parameter like resultFilter or statusFilter, it returned results.

1

1 Answers

1
votes

According to https://docs.microsoft.com/en-us/rest/api/azure/devops/build/latest/get?view=azure-devops-rest-6.0 the name following latest REST resource is the pipeline definition name or ID. This error means you have no pipeline named succeeded. This is the entire API call:

GET https://dev.azure.com/{organization}/{project}/_apis/build/latest/{definition}?api-version=6.0-preview.1

where

definition = definition name with optional leading folder path, or the definition id

You should double check you pass the correct pipeline definition ID after latest.