It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating Pull Request on Behalf of Team Members via API

Drew Purkett Jul 12, 2018

I've been attempting to create a pull request on behalf of our team members in an autonomous manner.

I'm able to create the pull request if I authenticate as the particular user with their username and password, but if I attempt to provide an alternative author username, per the swagger documentation, the field is ignored and only the administrator account is permitted.

Is there an authentication mechanism in place, short of having every team member complete the OAUTH procedure (Not practical), in which I am able to perform the desired API call and specify an author?

Sample call, which succeeds, but uses the username specified in the auth header. I have not yet attempted to setup authentication with OAUTH: 

curl -X POST -H "Content-Type: application/json" -u ...:... https://bitbucket.org/api/2.0/repositories/.../.../pullrequests -d '{
"title": "...",
"description": "...",
"source":
{
"branch":
{
"name": "..."
},
"repository":
{
"full_name": ".../..."
}
},
"destination":
{
"branch":
{
"name": "..."
}
},
"close_source_branch": false,
"author": {
"type": "user",
"username": "...",
"display_name": "...",
"account_id": "...:...-...-...-...-...",
"links":
{
"self":
{
"href": "https://bitbucket.org/!api/2.0/users/..."
},
"html":
{
"href": "https://bitbucket.org/.../"
},
"avatar":
{
"href": "https://bitbucket.org/account/.../avatar/"
}
},
"type": "user",
"uuid": "{...}"
}
}'

 ...also why was this marked as spam the first time I posted?

1 answer

0 votes
Ana Retamal Ortiz Atlassian Team Aug 09, 2018

Hi Drew, if I understand your request correctly, you'd like to use the API so you can authenticate as the administrator and create a pull request on behalf of a different user (without the need to authenticate as such user, is that right?

If so, I'm afraid it won't be possible. The pull request author can't be changed once it's been created, and at the time of creation the author is the authenticated user. We have a feature request to make the author editable, you might be interested in voting for it at Issues #11340. You can also add a comment and watch it to receive future notifications.

Regarding the post going to spam, it happens sometimes that our spam filter sends messages with code blocks to the spam category. The Community moderators are monitoring the Spam filter daily, but we're not always that fast and sometimes it can take longer to rescue the legit messages :) 

Let us know if you have any other questions!

Kind regards,

Ana

Drew Purkett Aug 09, 2018 • edited

Hi Ana!

While editing an already created PR would be great, and would be one solution to address our teams issue, my question was regarding defining the pull request author at time of creation.


The swagger definition for the PR creation endpoint allows specifying an author, but it is ignored in practice, and only the authorized user is ever used. My primary question is thusly: is this is an error in the specification?

OAUTHing every single developer on a team in order for an automated PR creation tool to work on behalf of the team of an internal product is simply not practical. I'm wondering if there is an authentication protocol, perhaps using credentials that belong to the team as a whole, or another way to authenticate besides OAUTH, that makes defining the pull request author at time of creation possible.

Best,

- Drew

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,809 views 1 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you