Azure / Azure/azure-rest-api-specs

createdBy value does not set Pull Request creator when using ADO Create Pull Request REST API

Open
#10,797 11 comments 3 reactions 0 assignees View on GitHub
DevOps question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

Hi, I'm not sure if this is the right place for this, but there seems to be a bug in the [Create Pull Request REST API](https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/create?view=azure-devops-rest-6.0).

The Request Body section of the docs says that you can pass in a "CreatedBy" value when creating a PR. However, no matter what I pass here, the creator of the PR is always the person/account associated with the bearer token that is passed in the header. I think there is either a bug with the API, or the documentation is wrong. Could you provide clarity? The same thing seems to be true for the "autoCompleteSetBy" property. Here is an example of what I'm doing:

```
# Get PR created by someone else on my team
$getEndpoint = "https://dev.azure.com/$organization/_apis/git/pullrequests/$($pullRequestId)?api-version=4.1"
$examplePR = Invoke-RestMethod -Uri $getEndpoint-Method GET -Headers $header -ContentType application/json

# Use the IdentityRef from the example PR as the "createdBy" value in a new PR
$postEndpoint ="https://$organization.visualstudio.com/$project/_apis/git/repositories/$repoId/pullrequests?api-version=5.1"
$body = @{
createdBy = $examplePR.createdBy
sourceRefName= "refs/heads/mybranch"
targetRefName = "refs/heads/develop"
title = "Automated PR test"
}

Invoke-RestMethod -Uri $postEndpoint -Method POST -Headers $header -Body (ConvertTo-Json $body) -ContentType application/json
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked Azure DevOps Create Pull Request REST API documentation and reproduce the provided PowerShell request using the createdBy and autoCompleteSetBy values. Compare the request fields with the resulting pull request identity and determine whether the API behavior or the documentation is incorrect; done means the expected behavior is clearly established and the relevant specification or documentation is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
api, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.