REST API for issue detail no longer returns the associated branches

Paul Becker February 19, 2020

Hi,

While I understand these are not documented APIs I think you used to be able to get the branches associated with an issue using a call like the following:

https://alterian.atlassian.net/rest/dev-status/latest/issue/detail?issueId=119044&applicationType=bitbucket&dataType=branch

This issue has a linked commit to a particular branch so I was anticipating that this call would return that branch.

Has this changed - and if so, is there any other way to get the branch information

1 answer

1 accepted

0 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2020

Hi @Paul Becker ,

Even if it is an internal endpoint it still works fine. It's just that you should use details instead of detal:

https://XXXXX.atlassian.net/rest/dev-status/latest/issue/details?issueId=10196&applicationType=bitbucket&dataType=branch

 

Please use 'details' in the endpoint you are calling and confirm this works.

 

Cheers,
Dario

Paul Becker February 20, 2020

Hi Dario. Thanks for your reply.

Using details rather than detail does give me a bit more information about the commits but still doesn't include any branch information - unless I also have a linked pull request.

As it stands I guess I would need to take the commit id and look up the branch via bitbucket, but I think you used to get the branch info directly in the branches array?

 

 "errors": [],
"detail": [
{
"branches": [], -- I think this used to be populated when you had an associated commit
 

Thanks,

Paul

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2020

Hi @Paul Becker ,

I am not sure I understand correctly, but I can see branches information being returned whether I use the endpoint 

/rest/dev-status/latest/issue/summary?issueId=

OR:

/rest/dev-status/latest/issue/details?issueId=

 

Example:

curl -v -u <EMAIL-ADDRESS>:<API-TOKEN> "https://<NAME>.atlassian.net/rest/dev-status/latest/issue/details?issueId=10196" | json_pp 


% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10391 0 10391 0 0 5668 0 --:--:-- 0:00:01 --:--:-- 5668

{
"errors": [

],
"detail": [
{
"branches": [
{
"name": "feature/KFF-39-test",
"url": "https://bitbucket.org/{}/{edcb945a-5aee-XXXXXXXXXXXX}/branch/feature/KFF-39-test",
"createPullRequestUrl": "https://bitbucket.org/{}/{edcb945a-XXXXXXXXXXXXXX}/pull-requests/new?source=feature/KFF-39-test",
"repository": {
"name": "New_repo1",
"avatar": "https://bytebucket.org/ravatar/%7Bedcb945XXXXXXXXXXXXXXXX7%7D?ts=default",
"url": "https://bitbucket.org/{}/{edcb945a-5aee-44XXXXXXXXXXXX06d07}",
"commits": [

]
},
"lastCommit": {
"id": "2847fb7981b1b0e0XXXXXXXXXXXX88085f4",
"displayId": "2847fb7",
"authorTimestamp": "2020-02-12T13:15:15.000+0000",
"merge": false,
"files": [

]
}
}
],

OR:

curl -v -u <EMAIL-ADDRESS>:<API-TOKEN> "https://<NAME>.atlassian.net/rest/dev-status/1.0/issue/summary?issueId=10196" | json_pp

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1116 0 1116 0 0 2364 0 --:--:-- --:--:-- --:--:-- 2359
{
"errors" : [],
"summary" : {
"deployment-environment" : {
"overall" : {
"showProjects" : false,
"successfulCount" : 0,
"count" : 0,
"lastUpdated" : null,
"dataType" : "deployment-environment",
"topEnvironments" : []
},
"byInstanceType" : {}
},
"branch" : {
"byInstanceType" : {
"bitbucket" : {
"name" : "Bitbucket Cloud",
"count" : 1
}
},
"overall" : {
"count" : 1,
"dataType" : "branch",
"lastUpdated" : "2020-02-12T14:15:15.000+0100"
}
},

 

Can you kindly perform the same tests, share what you get and provide a bit more details on what would you expect to see instead? 

 

Cheers,
Dario

Paul Becker February 21, 2020

Hi Dario,

Maybe I am misunderstanding now a branch gets linked to a JIRA issue. I had assumed that a linked commit would also cause its branch to be linked? Do I have to do something extra to link the branch?

I get the following:

 

 https://alterian.atlassian.net/rest/dev-status/latest/issue/details?issueId=115254&applicationType=bitbucket&dataType=branch

 

{"errors":[],"detail":[{"branches":[],"pullRequests":[{"author":{"name":"Tim Shire","avatar":"https://secure.gravatar.com/avatar/94aa4d7ae2f0369ec1ba193d5bbd293d?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FTS-1.png&size=48&s=48"},"id":"220","name":"dev-800 Initiatives API's (Create / Get / Edit / Delete)","commentCount":0,"source":{"branch":"feature/dev-800","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/branch/feature/dev-800"},"destination":{"branch":"master","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/branch/master"},"reviewers":[{"name":"Paul Becker","avatar":"https://secure.gravatar.com/avatar/55daf92e9d032ca50ba85aca6fbea6c6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPB-6.png&size=48&s=48","approved":false}],"status":"DECLINED","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/pull-requests/220","lastUpdate":"2020-02-19T10:01:50.524+0000"}],"repositories":[],"_instance":{"singleInstance":true,"baseUrl":"https://bitbucket.org","name":"Bitbucket","typeName":"Bitbucket Cloud","id":"bitbucket","type":"bitbucket"}},{"repositories":[{"name":"Campaign Manager","avatar":"https://bytebucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/avatar","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}","commits":[{"id":"16c77aa90ef9ef5719d818b140ade0c930f53a5e","displayId":"16c77aa","authorTimestamp":"2020-02-17T11:13:38.000+0000","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/commits/16c77aa90ef9ef5719d818b140ade0c930f53a5e","author":{"name":"Paul Becker","avatar":"https://secure.gravatar.com/avatar/55daf92e9d032ca50ba85aca6fbea6c6?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPB-6.png&size=48&s=48"},"fileCount":1,"merge":false,"message":"DEV-800 Add new stored procs to project\n","files":[{"path":"Database/Database.sqlproj","url":"https://bitbucket.org/{}/{d4907970-2144-4d6a-9e4a-d14f89eac08a}/commits/16c77aa90ef9ef5719d818b140ade0c930f53a5e#chg-Database/Database.sqlproj","changeType":"MODIFIED","linesAdded":6,"linesRemoved":0}]}]}],"_instance":{"singleInstance":true,"baseUrl":"https://bitbucket.org","name":"Bitbucket","typeName":"Bitbucket Cloud","id":"bitbucket","type":"bitbucket"}}]}

 

and for:

 https://alterian.atlassian.net/rest/dev-status/latest/issue/summary?issueId=115254

"errors":[],"configErrors":[],"summary":{"pullrequest":{"overall":{"count":1,"lastUpdated":"2020-02-19T10:01:50.524+0000","stateCount":1,"state":"DECLINED","dataType":"pullrequest","open":false},"byInstanceType":{"bitbucket":{"count":1,"name":"Bitbucket Cloud"}}},"build":{"overall":{"count":0,"lastUpdated":null,"failedBuildCount":0,"successfulBuildCount":0,"unknownBuildCount":0,"dataType":"build"},"byInstanceType":{}},"review":{"overall":{"count":0,"lastUpdated":null,"stateCount":0,"state":null,"dueDate":null,"overDue":false,"dataType":"review","completed":false},"byInstanceType":{}},"deployment-environment":{"overall":{"count":0,"lastUpdated":null,"topEnvironments":[],"showProjects":false,"successfulCount":0,"dataType":"deployment-environment"},"byInstanceType":{}},"repository":{"overall":{"count":1,"lastUpdated":"2020-02-17T11:13:38.000+0000","dataType":"repository"},"byInstanceType":{"bitbucket":{"count":1,"name":"Bitbucket Cloud"}}},"branch":{"overall":{"count":0,"lastUpdated":null,"dataType":"branch"},"byInstanceType":{}}

Thanks,

Paul

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2020

Hi @Paul Becker ,

As written in the Referencing issues in your development work documentation page, in order to have a branch linked to a Jira issue you have to include the issue key in the branch name.

For example, in my case you can see:

"branches": [
{
"name": "feature/KFF-39-test",

 

We do have the below feature requests open in our system to add the possibility to link already existing branches or to be able to link a branch without having to include the issue key in its name but they haven't got much traction so far:

You may want to vote and watch the above feature requests so that you will get notified in case of any update. The  features will be addressed according to the Implementation of New Features Policy

 

Also, for more details, you may want to review the below links:

 

Have a nice weekend.

 

Dario

Paul Becker February 24, 2020

Thanks Dario, but my issue name is in the branch name. I think it shows in the details trace above (via the source entry but not the branches item)

 

"name":"dev-800 Initiatives API's (Create / Get / Edit / Delete)","commentCount":0,"source":{"branch":"feature/dev-800"
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 25, 2020

Hi @Paul Becker ,

The issue key in your branch name is lowercase while, as mentioned in the provided documentation pages, it has to be uppercase (same as in Jira).

  • Integrating with development tools
    Note that the issue key must conform to the default Jira key format – that is, two or more uppercase letters ([A-Z][A-Z]+), followed by a hyphen and the issue number. For example, ABC-123.
  • Referencing issues in your development work
    In all cases, the issue key must use to the default Jira key format – that is, two or more uppercase letters ([A-Z][A-Z]+), followed by a hyphen and the issue number. For example, ABC-123.

Can you kindly change the branch name from dev-800 to DEV-800 and let us know if this works?

 

Cheers,
Dario

Paul Becker February 25, 2020

Thanks Dario, I noticed the same this morning and have managed to get a branch back :) - and now seem to be stuck on this issue instead!

https://community.atlassian.com/t5/Jira-questions/SDK-name-vs-displayName-userPicker-NullReferenceException-in/qaq-p/1303712

 

There don't seem to be any updates on this though :(

Like Dario B likes this
Paul Becker February 25, 2020

Thanks so much for your help on getting to this point though!

Like Dario B likes this
Paul Becker February 25, 2020

And it looks like there is a new alpha release to help work around the other issue. Once again, thanks for your help - and I guess I can close this now!

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2020

You are very welcome @Paul Becker  and thanks for sparing some time to accept the solution.

I can indeed see that the new issue you are talking about was fixed as part of: 

Also, for the future, please notice that:

  1. The officially supported Atlassian SDK is for Jira Server only and it is the one documented in:   
  2. The SDK you are using is actually maintained by its Repository owner. You can see the known issues (solved or not) and create a new ones (in case of any problem) by using the following link: 
  3. In order to get support on development related issues, please refer to the resources are listed in https://developer.atlassian.com/resources. Specifically:


I hope this helps.

I will now go update the other thread with this information as well :) 

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer