azure-rest-api-specs icon indicating copy to clipboard operation
azure-rest-api-specs copied to clipboard

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

Open thealanagrace opened this issue 4 years ago • 6 comments

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.

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

thealanagrace avatar Sep 15 '20 20:09 thealanagrace

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.

ghost avatar Sep 17 '20 03:09 ghost

@narula0781, @ashishonce, @romil07, is there an update on this? I would like to use the CreatedBy field when creating the PR programmatically. I am creating the PR as part of an ADO build pipeline, and I would like to customize the PR so that it is created by the person who triggered the pipeline.

thealanagrace avatar Oct 06 '20 17:10 thealanagrace

Any update on this? I'm in the same boat.

jabbera avatar Aug 25 '21 13:08 jabbera

Same issue here, can we have an update please?

hobbesuk avatar Nov 09 '21 08:11 hobbesuk

Same here. we have a pipeline that creates the PR on behalf of the author, but since we can't get the CreatedBy field right, we're having issues later on with comments not being shown and approvals.

gilkgit avatar Dec 13 '21 06:12 gilkgit

Any update on this?

ristics18 avatar Dec 22 '22 15:12 ristics18

Would love to see an update on this.

YakaryBovine avatar Apr 14 '23 01:04 YakaryBovine

+1

shayki5 avatar Apr 19 '23 19:04 shayki5

tumbleweed-gif-6

Piatnytskyi avatar Feb 09 '24 13:02 Piatnytskyi

Any update on this?

HyruleConsulting avatar May 17 '24 11:05 HyruleConsulting