Hello community,
I am trying to update JIRA issue statuses by using a python script / Jira rest API post request. When I run the code there is an error 400 happening. Could someone help me debugging it?
Here is the code:
import requests
import json
# set the user name and password values
b64Val = 'xxxxxxxx'
# set the url and headers
url = "https://jira.xxxx.com/rest/api/2/issue/ISSUENUMBER-27/transitions?expand=transitions.fields"
header={"Authorization": "Basic %s" % b64Val, 'Content-Type': 'application/json'}
# simulating that the transition id will be status : TO DO
json = {"transitions": {"id": {1021}}}
#make the authenticated request to the JIRA API
r = requests.post(url, headers=header, data=json)
print ("HERE's the JSON RESPONSE\n\n ", r.status_code, r.headers)
print ("The response content is\n\n", r.content)
here is the error :
C:\Users\xxxxxx\PycharmProjects\xxxxxxx\xxxxxx>python test.py
("HERE's the JSON RESPONSE\n\n ", 400, {'X-ANODEID': 'ip-XX-X-XX-XXX.cloud.xxx.xxx.xxx', 'X-AUSERNAME': 'username', 'X-AREQUESTID': 'x58s6s5s6s5s1', 'X-Content-Type-Options': 'nosniff', 'Set-Cookie': 'JSESSIONID=3531C3F5E4dsdswe4444YR5B0FC5E5BFB;path=/;Secure;HttpOnly, atlassian.xsrf.token=BewweeH-3wewwP-VUG5-XCF2|252acbad9796ee1a9edb7bdectertertdfgf892f98dfe8f113|lin;path=/;Secure, AWSELB=DFA36D911ED9431079EA8A40E7B6sdfse324323423423532523809037333779072394E19436D8D7FA102AB26B5CCEC572A30E7146BA427A4007D7077583;PATH=/;SECURE;HTTPONLY', 'X-Seraph-LoginReason': 'OK', 'X-ASEN': 'SEN-104345443455', 'X-ASESSIONID': 'kk33434t', 'Content-Length': '193', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Fri, 20 Jul 2018 20:19:27 GMT', 'Content-Type': 'application/json;charset=UTF-8'}) ('The response content is\n\n', '{"errorMessages":["Unrecognized token \'transitions\': was expecting \'null\', \'true\', \'false\' or NaN\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@2aa15555d347; line: 1, column: 13]"]}')