Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to get all workflow steps through rest api

I know I can use /rest/api/2/workflow and it returns a json of all the workflows with some data.

I would like to get all the workflow steps also but cannot find such function on the rest api. Am I missing something?

Thanks

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Pedro Cora Atlassian Team Sep 08, 2013

Hi Mauricio,

You can use the transitions REST call on a given issue. When running this call, the result will be the available steps. For more details, check out https://docs.atlassian.com/jira/REST/latest/#idp1937248

Cheers,

Pedro

Hey Pedro, thanks for the quick answer. Well that method does return the available transitions depending on the issue id and the current status of such issue, which is good.

Let me explain a little bit further what I am trying to solve here. We are integrating Jira API with a 3rd party ERP and before the user creates an issue, just after selecting the issue type I need to display him which are the transitions for that issue type.

This is a requirement for my client. I was thinking if rest api doesn't have that method, maybe the old soap does. An xml or json would work great for our porpouses.

If I was clear enough and you have any clue, that would be just great. I am accepting your answer because it makes sense and the original question was lacking this detailed explanation.

Kind regards.

Haha, it was lot easier than I imagined. Just copied the url when exporting the workflow and that would get me the XML itself. Then I just need to parse into each STEP node.

Hi Mauricio! I wanted to be able to do this programmatically but had to jump through a few hoops to get past websudo authentication. It took me a little while to put all the pieces together and since this answer popped up on my Google search, I'll post my solution here

#!/bin/bash

USERNAME=$1

JIRA_URL=https://my.jira.com
COOKIES=cookies.txt
HEADER="X-Atlassian-Token: no-check"

echo -n "Password: "
read -s PASSWORD
echo

echo Logging in...
curl -s -c "$COOKIES" -H "$HEADER" -d "os_username=$USERNAME" -d "os_password=$PASSWORD" -d "os_cookie=true" $JIRA_URL/login.jsp > /dev/null

echo Authenticating as administrator...
curl -si -c "$COOKIES" -b "$COOKIES" -H "$HEADER" -d "webSudoPassword=$PASSWORD" -d "os_cookie=true" -d "webSudoIsPost=false" -d "authenticate=Confirm" $JIRA_URL/secure/admin/WebSudoAuthenticate.jspa > /dev/null

echo Fetching XML...
curl -s -b "$COOKIES" -H "$HEADER" -d "os_cookie=true" -d "webSudoIsPost=true" --output output.xml "${JIRA_URL}/secure/admin/workflows/ViewWorkflowXml.jspa?workflowMode=draft&workflowName=My+Workflow+Name"

echo Cleaning up...
rm $COOKIE

This was adapted from the accepted answer by @Phillip Ponzer here https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-Call-Canned-Builtin-Script-Runner-Scripts-from-a-Script/qaq-p/466583

In this example I'm reading the username as an argument and the password from stdin, so not really 'automatic'  but people can do whatever is appropriate if they want to integrate it with other code. Hope it helps someone.

Like Martin Cleaver likes this

I was trying to get the complete underlying workflow XML via REST but didn't see a way. Maybe get the ids somehow but the obvious workflow REST call doesn't return that, which is odd

Does each workflow have id of sort? Cuz if you just type in yourcompany.com//rest/api/2/workflow how does it know to get which issue workflow to return? 

I think it matches with the name of the workflow itself. Right now I don't have a Jira to test, but you could give it a try. Cheers.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS

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