Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pull request creation - bad request 400

Tim Piot August 12, 2021

Hello,

I have troubles creating a pull request via the bitbucket api. In my opinion I'm respecting the constraints of the format on how to approach the endpoint based on the documentation and other tickets in this space but I'm always receiving some vague error response "BAD REQUEST 400". 

Documentation:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pullrequests

Here the "resource url"  and the url used in the documentation are not the same but both lead to BAD REQUEST 400 to me.

 

image.png

Attempt:

image.png

Other ticket:

https://community.atlassian.com/t5/Bitbucket-questions/how-to-create-bitbucket-pull-request-using-bitbucket-rest-api/qaq-p/906404

I use Postman and can access the resource to retrieve pullrequests:

image.png

But for the pull request creation I always have a bad request returning:

image.png

Evidence "develop" exists:

image.png

Is there something that I'm overlooking? Thanks!

Kr

Tim

 

1 answer

1 accepted

0 votes
Answer accepted
Tim Piot August 13, 2021

Hello @seanaty ,


Sorry for tagging you but you seem very knowledgeable on the topic (you solved the ticket I referenced to in the post). Would you, by any chance, be able to glance over this? I'm probably overlooking something basic.

Tim

seanaty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 13, 2021

Based on the findings here: https://community.atlassian.com/t5/Bitbucket-questions/Re-Re-how-to-create-bitbucket-pull-request-using-bitbuc/qaq-p/912414/comment-id/33847#M33847 you can't actually add the authenticated users as a reviewer (check and see if you're doing that).

Lastly I would use UUID instead of username as that's generally been phased out.

I would also omit repository from both source and destination as they are redundant (the repository is already specified in the path). The only reason you'd need to specify a repo in the body is in the case of a pull request of a fork. I suspect that there is a problem with the body input with regard to how we identify a repository. We likely need to have the repository `full_name` or a `workspace` object to correctly lookup the repository. All that said, your best bet is to remove it from the body entirely.

Tim Piot August 17, 2021

Hello,

 

Thank you for your response and your input. It was highly appreciated. I implemented it but not yet with success. There was also an extra semicolon after "develop" causing issue.

image.png

So now he still can't find the repository. He authenticates my user but can't find the repo associated. The same happens when I execute a GET:

image.png No repositories are found with my username which is not correct...
I do have 2 workspaces (personal + shared ) for my account but both have repos while this get doesn't return anything. Maybe this has something to do with that?


Again I'm desperate for help. Do you maybe have another idea or do you know another expert? :)

Thanks!

seanaty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 17, 2021

Ah ok, this then is an authentication issue. When you look at your list of repos and see "0" that means you have private repositories (and no public repositories). As you are not authenticated correctly you see what the public and/or unauthenticated users see. Namely a list of your public repositories (which, in this case, happens to be 0).

You can use the /2.0/user API to see who you are currently authenticated as (or if you're authenticated)

Tim Piot August 23, 2021

I finally got it working. Thank you for guiding me in the right direction.

If it helps for someone else later.
2 things:

* Pull Request "Write"-rights aren't enough

* The documentation of Atlassian is not correct:
image.png

 

Unlike in the explicit example in the documentation above, to POST a new pull request you shouldn't connect via "repositories/my-username" but via "/{workspace}/{repo_slug}"


image.png



seanaty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2021

Good catch about the documentation. I'll make a task to update the example. The parameter name is "workspace" but it used to actually be "username" of of the team, hence the example currently says "my-username".

Like Tim Piot likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events