Here is the simple method:
- Generate below url for POST request
https://dev.azure.com/**{OranizationName}**/_apis/Contribution/HierarchyQuery/project/**{ProjectID}**?api-version=5.0-preview.1
- Refer this link for any value you need
https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1
- Use below Json as a request param
{"contributionIds":["ms.vss-code-web.pr-detail-data-provider"],"dataProviderContext":{"properties":{"pullRequestId":{PullRequestID},"repositoryId":"{repositoryId}","sourcePage":{"url":"https://dev.azure.com/{OrganizationName}/{ProjectName}/_git/{RepositoryName}/pullrequest/{PullRequestID}?_a=files"}}}}
- Send POST request
- Get Count from highlighted property to get the file count for each PR
6. Create access token in Azure DevOps and use it for authentication
7. Provide Code and Token Administration access to token