Azure – Get All Pull requests using ADO DevOps API

API for automating Azure DevOps Pipelines trigger azure pipelines build api for automating azure devops

Today in this article, we will see Azure – Get All Pull requests using ADO DevOps API feature in detail.

It’s easy to call Azure DevOps API and get the pull request details. One can automate the process using the AZ command or CLI or PowerShell script.

We will use the below API for the same.

Trigger an ADO build- using Queue API

GET API

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo-name}/pullrequests?&api-version=6.0

Build pipeline With optional parameters

GET API

https://dev.azure.com/jan2022-thecodebuzz/globalexceptionhandler/_apis/git/repositories/globalexceptionhandler/pullrequests?&api-version=6.0

In the above Post request below are the input parameters,

  • organization – The name of the Azure DevOps organization.
  • project – Project ID or project name
  • api version – Version of the API to use.

Below is our sample repository,

https://dev.azure.com/jan2022-thecodebuzz/globalexceptionhandler/_build

Azure Get All Pull requests using ADO DevOps API

Configuration and security

Let’s now configure the API to be invoked securely.

Step1- Click on the User settings and set up the personal access token.

start a build and passing variables through azure devops rest api

Define a name for this token and authorize the scope of access with this token. You can choose this token access for the Build pipeline trigger or release pipeline trigger etc.

I have below sample 2 pull request

blank

Once you execute the GET API, all metadata associated with Pull request can be accessed easily ,

blank

References:



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *