Expose transition meta in REST API

XMLWordPrintable

    • 4
    • 3

      NOTE: This suggestion is for JIRA Cloud. Using JIRA Server? See the corresponding suggestion.

      There is currently no way to determine the possible set of transition names and IDs for a given combination of project and issue type (and possibly user for auth details?)

      The only way to transition an issue is by ID via the https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-doTransition endpoint

      If you want to do this by name, you can potentially hit the https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getTransitions endpoint, and in code find the ID for the name that matches, but that still requires having a particular issue to query.

      The other possibility is the https://docs.atlassian.com/jira/REST/cloud/#api/2/workflow endpoints - this frees one from finding a particular issue, but it still only provides transition meta for known IDs.

      I see lots of people asking how to do this, with the response that it's not possible:

      https://www.google.co.uk/webhp?sourceid=chrome-instant&rlz=1C5CHFA_enGB686GB686&ion=1&espv=2&ie=UTF-8#q=jira+rest+api+transition+id&*

      Use cases

       https://extranet.atlassian.com/display/~mscriven/2017/02/26/Sync+Backlog+Microservice

      I'd like to display a drop-down list of transition names to the user (once they've chosen an issue type), in a project admin screen, to select what transition to use when my service closes or re-opens an issue. At the moment the user must type this manually, risking an error. 

      Our own jhazelwood ran into the same issue for a similar requirement: https://extranet.atlassian.com/pages/viewpage.action?pageId=2502755497

      Failed workaround

      I noticed that this data is visible in the Workflow editor, both visually and as an XML export. I spent some writing code that parsed that, which worked: https://bitbucket.org/atlassian/syncjirabacklog/src/1ddc0bfedbfbc1dcb33c1799714510a3cbf479b7/src/main/java/io/atlassian/micros/syncbacklog/util/TransitionMetadataHelper.java?fileviewer=file-view-default

      However, I then hit a 403 when requesting from my Connect Addon service - I hadn't realised that Connect only allows a whitelisted sub-set of JIRA's URLs. Since the workflow export is not actually part of the API, the Connect team say this will not be whitelisted.

      Solution?

      Interestingly, there is a "transitions" endpoint: https://stash.atlassian.com/projects/JIRACLOUD/repos/jira/browse/jira-components/jira-plugins/jira-rest/jira-rest-plugin/src/main/java/com/atlassian/jira/rest/v2/admin/WorkflowsResource.java#88

      However, that only returns the transition as a sub-resource by ID (hence the limitation) https://stash.atlassian.com/projects/JIRACLOUD/repos/jira/browse/jira-components/jira-plugins/jira-rest/jira-rest-plugin/src/main/java/com/atlassian/jira/rest/v2/admin/WorkflowTransitionResource.java#74

      I think the solution may simply to be add a further index "/" path to the WorkflowTransitionResource that returns them all (rather than just the /properties/{id} endpoint).

            Assignee:
            Unassigned
            Reporter:
            Marcos Scriven (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: