How to build the payload for a status update (transition) restkit Resource

Hi, I've seached for an example of how to build the payload for a status update (transition). I've tried something like this:

pdata = {"transitions": {"id":"81","name":"Systemtest av leveransen","to":{"self":"http://jira.adeo.no/rest/api/2/status/10190","description":"","iconUrl":"http://jira.adeo.no/images/icons/statuses/generic.png","name":"Systemtest av leveransen","id":"10190"},"fields":{}}}

...

response = resource.put(headers={ "Content-Type": "application/json" }, payload=json.dumps(pdata))

I get errors like these:

c:\Python27\Doc>python set_status.py

EXCEPTION: {"errorMessages":["one of 'fields' or 'update' required"],"errors":{}}


If I use pdata = {"fields": {"status": { ... i get

c:\Python27\Doc>python set_status.py

XCEPTION: {"errorMessages":[],"errors":{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}}

I can update other simple fields . But find transtions like stataus complicated.

If i expand the transition with:

http://jira.adeo.no/rest/api/2/issue/PKGIRAFF-1/transitions?expand=transitions.fields

I get


{"expand":"transitions","transitions":

[{"id":"81","name":"Systemtest av leveransen","to": {"self":"http://jira.adeo.no/rest/api/2/status/10190","description":"","iconUrl":"http://jira.adeo.no/images/icons/statuses/generic.png","name":"Systemtest av leveransen","id":"10190"},"fields":{}}, {"id":"91","name":"Tilbake til systemtest i iterasjonen","to":{"self":"http://jira.adeo.no/rest/api/2/status/10188","description":"","iconUrl":"http://jira.adeo.no/images/icons/statuses/generic.png","name":"Systemtest i iterasjonen","id":"10188"},"fields":{}}

]

}

I've checked https://docs.atlassian.com/jira/REST/5.2/#id251679 but i find it complicated to understand.

Can someone, please, help me with som tips an syntax tip. It's a bit complicated to understand. I think I need a concrete/spesific tip. I'm sure it's simple when it's build correctly - but there are so many combinations.

Please help me :-)

Thanks a lot.

1 answer

The problem was that I had to use POST, not PUT.

The payload got really simple:

{
'transition': {
'id': 81 # Resolved (for my setup)
}}
I now got HTTP 405. This is most probably related HTTP/HTTPS.
I found it much more simple to use urllib instead of restkit. See my final solution below:
import urllib
import urllib2
import base64
import json
key = 'MYISSUE'
#comment = "It's done!"
username = 'xxxx'
password = 'yyyy'
auth = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
data = json.dumps({
'transition': {
'id': 81 # Resolved (for my setup)
}
})
request = urllib2.Request(url, data, {
'Authorization': 'Basic %s' % auth,
'Content-Type': 'application/json',
})
print urllib2.urlopen(request).read()

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

93 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you