I am able to create a pull request from command line, the only thing I find painful is the reviewers are specified by UUID, I can see why that is safest but is there another way? Right now:
"reviewers": [
{
"uuid": "{4ebe61bf-...-a368a41c78f6}"
},
{
"uuid": "{2ce53e84-...-fff39d658b49}"
}
]
This is not very user-friendly, and I can't even put comments to indicate who those people are at least for whoever reads the PR.json that contains the above.
For 2.0 API:
In my case the main reason I use CLI is because I have a bunch of identical PR's to make on dozen repos, so the way I handle this now is I create one PR programmatically, use the CLI to get the PR, pare down the JSON so only title, description, reviewers, and source remain, and POST the file to as many repos as I need.
Hello @Oliver Schoenborn,
In the payload you send to the API endpoints you actually can refer to users using their usernames — you obviously need to know them in advance.
"reviewers": [
{
"username": "<username>"
}
]
In the API responses, however, usernames are not returned anymore due to requirements introduced by GDPR.
Note that a user might change their username at any time, and this will break a request with the payload mentioned above. Unlike username, UUID and Atlassian ID (uuid and account_id in JSON, respectively) would remain same in that case.
Hope this helps.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Daniil I tried username and got bad request error. I can use username if I also include uuid. Which is useful to document who the uuid is, but I still have to know the uuid.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm, did you get any error description in the response payload?
I'm able to create a PR using API with reviewers resolved by username:
❯ curl -X POST -H "Content-Type: application/json" -u detouched:pEPcSZYDpP4SmgDMbkL9 "https://api.bitbucket.org/2.0/repositories/detouched/docker-spb/pullrequests" -d '{
"title": "Test Pull Request",
"source": {
"branch": {
"name": "1.3.8"
}
},
"destination": {
"branch": {
"name": "master"
}
},
"reviewers": [
{
"username": "dpenkin"
}
]
}'
I get 201 back and PR object JSON.
So I'm wondering maybe you get bad request because of some other problem?
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No info beyond bad request. Likely because username invalid. I went to the user's page and could see the uuid in the link and their name on the page so I used that but that's probably their display name (and I tried with display_name instead of uuid or username but also got bad request). How can I find a user's username?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Usernames are not exposed anymore as they are personal data and hence are covered by the data protection regulations (GDPR). So the only way to get someone's username is by asking that person IRL.
Meanwhile I checked that although resolution by username still works right now, it is also deprecated and can be taken down at any time, see "Replace username fields with Atlassian Account ID (account_id)" section in the deprecation notice.
As for the case when you use username together with UUID, the former is simply ignored as the latter has a preference. So a hacky workaround for inability to leave comments in JSON would be to use username for a hint of who does the uuid refers to. Interestingly, account_id has lower preference than username, so same trick wouldn't work if you decide to use it as identifier. I'll raise a change to fix that as it now makes more sense I believe.
All in all, this definitely complicates your workflow but is the inevitable tradeoff for privacy aspect on the other hand. Let me know if you have any questions.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the info and following up. I must say I think the privacy issue is inadvertently tied to this, and should not be tied to it by design; if you pick a reviewer, you should have a way of identifying them by name; if you're not allowed to use username, then a nickname, or just their display name since that is what is available in the interface, something that is not a UUID! Anyway, at least I can get the mapping by generating a PR from the GUI with the reviewers I want, although this is a bit of a pain it si better than nothing. Thanks for all your support.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks, good to know (unfortunately I'm using 2.0)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @thinksabin,
Just a heads up that REST API 1.0 has been deprecated around a year ago and currently is in a phase of gradual termination. So the endpoints you might still be able to use now will likely stop working in the future. Please consider migrating to API 2.0.
Let me know if you have any questions.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Daniil Penkin ,
thanks for the heads up, I was unaware about the termination of the api 1.0. Thanks i will try to modify my automation script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.