1

There are 1 best solutions below

0
On

I tried using commits rest api but it's listing the entire commit instead of the expected ones.

In order to get the list of commits between two commits, it is better to use searchCriteria.fromDate={searchCriteria.fromDate}&searchCriteria.toDate={searchCriteria.toDate}. It will provide you the commits as per the created date.

If you intend to use searchCriteria.fromCommitId={searchCriteria.fromCommitId}&searchCriteria.toCommitId={searchCriteria.toCommitId}, then it will provide you results either in alphabetical order if commit Ids are started with letters like a*****1 to g*****0 or in numerical order if commit Ids are started with numbers like 0*****321 to 5******g23.

I am using the below URL-

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?searchCriteria.fromDate={searchCriteria.fromDate}&searchCriteria.toDate={searchCriteria.toDate}&api-version=7.1-preview.1

I am getting the expected results as shown below-

enter image description here

References-

Rest-api-to-get-all-commit-info-between-base and target commit.