Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,021
Community Members
 
Community Events
168
Community Groups

Issues in updating custom field of a JIRA in python

I have a JIRA Ticket where I am trying to update the field of "Verified Version:" of the Ticket to something like "ABC 1.0"
The REST API name for "Verified Version:" is "customfield_11361".
When updated the version manually, it looks like below:
"customfield_11361": [
      {
        "self": <API_URL>,
        "id": "104743",
        "description": "",
        "name": "ABC 1.0",
        "archived": false,
        "released": false,
        "releaseDate": "2022-07-31"
      }
    ]
When not version is updated, it looks like below:
"customfield_11361": [
    ] 
When tried from python interpreter, I get the following results.
>>> from jira import JIRA
>>> headers = {}
>>> headers["Authorization"] = "Bearer <Token_key>"
>>> jira_obj = JIRA(server=<JIRA_Server_URL>, options={"headers":headers})
>>> jira_obj.issue(<JIRA_Ticket>)
<JIRA Issue: key=u'<JIRA_Ticket>', id=u'1247768'>
>>> jira_obj.issue(<JIRA_Ticket>).fields.customfield_11361
[<JIRA Version: name=u'ABC 1.0', id=u'104743'>]
>>> jira_obj.issue(<JIRA_Ticket>).fields.customfield_11361[0]
<JIRA Version: name=u'ABC 1.0', id=u'104743'>
...
Cleared the verified version manually in the JIRA Ticket directly.
...
>>> jira_obj.issue(<JIRA_Ticket>).fields.customfield_11361
[]
>>> jira_obj.issue(<JIRA_Ticket>).update({'customfield_11361': [{'name': 'ABC 1.0'}]})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resources.py", line 412, in update
    super(Issue, self).update(async=async, jira=jira, fields=data)
  File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resources.py", line 178, in update
    self.self, data=data)
  File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 136, in put
    return self.__verb('PUT', url, **kwargs)
  File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 126, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 45, in raise_on_error
    r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 415
        url: <API_URL>
        response headers = {'X-ANODEID': 'JiraProd_i-0ff79dea69bc39a25_10.150.20.84', 'X-AUSERNAME': 'svc.eng.jirautotriag', 'Content-Length': '0', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Set-Cookie': 'AWSALBTG=30RQv3GKZcjCtYxL2RGbsbH8yLx1ey8ma64o2iaAZUA/7Nm/r5cAGQ0FmfvnzKLZt8SMshr7J6+dF6pRrFR2p608sS2pmYoHoevjiesIvqEi5AY0Xnvxe93mePiHpM6nN55WMTqV9CkTC0opuuQVnp+c/UZ2ZYnyONCEiuiFOQ7grK1nmn8=; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/, AWSALBTGCORS=30RQv3GKZcjCtYxL2RGbsbH8yLx1ey8ma64o2iaAZUA/7Nm/r5cAGQ0FmfvnzKLZt8SMshr7J6+dF6pRrFR2p608sS2pmYoHoevjiesIvqEi5AY0Xnvxe93mePiHpM6nN55WMTqV9CkTC0opuuQVnp+c/UZ2ZYnyONCEiuiFOQ7grK1nmn8=; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/; SameSite=None; Secure, JSESSIONID=93EB48BE1E6601CA9D0F5F1B2065C062; Path=/; Secure; HttpOnly, atlassian.xsrf.token=B14E-GL73-6FKZ-OP3B_a78d88ea0c35e582f026ada3d9f98b6ece47285f_lin; Path=/; Secure, AWSALBAPP-0=AAAAAAAAAAA3k++saeQ+htH2m7IzGNyst8sx9HUMRQ3aJCFVRuxgIlV4QIoLMgM32mgmZI+o0hsK93RUPAeVl2tzJpmfjup20SVnealEWGbmqDdtpdatO6rxxsLx+H1qYI19avkc0Xbxkss=; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/, AWSALBAPP-1=_remove_; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/, AWSALBAPP-2=_remove_; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/, AWSALBAPP-3=_remove_; Expires=Sun, 25 Sep 2022 06:28:00 GMT; Path=/', 'X-Seraph-LoginReason': 'OK', 'Strict-Transport-Security': 'max-age=31536000', 'X-AREQUESTID': '388x3995248x3', 'X-ASESSIONID': '1nq6mq5', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Sun, 18 Sep 2022 06:28:00 GMT', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Type': 'text/html;charset=UTF-8'}
        response text =
The HTTP 415 means "the server refuses to accept the request because the payload format is in an unsupported format." in general.
Any suggestions as to properly form the date in order to update?

I have removed the confidential JIRA URLs, Access Token, etc... for security reasons. I hope that is fine.

Please assist. Thanks in Advance.

1 answer

0 votes

Hi,

Can you try this:

issue.update(fields={'customfield_11361': [{'name': 'ABC 1.0'}]})

I had tried this as well but yields with the same results unfortunately

>>> jira_obj.issue("ENG-488911").update(fields={'customfield_11361': [{'name': 'ABC 1.0'}]})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resources.py", line 412, in update
super(Issue, self).update(async=async, jira=jira, fields=data)
File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resources.py", line 178, in update
self.self, data=data)
File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 136, in put
return self.__verb('PUT', url, **kwargs)
File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 126, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/home/naveen.shankar/auto_validator/my_nutest_virtual_env/lib/python2.7/site-packages/jira/resilientsession.py", line 45, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 415
url: https://jira.nutanix.com/rest/api/2/issue/1247768
response headers = {'X-ANODEID': 'JiraProd_i-0079ce0126cf8d38c_10.150.20.8', 'X-AUSERNAME': 'svc.eng.jirautotriag', 'Content-Length': '0', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Set-Cookie': 'AWSALBTG=Uxxfmb3lHmPRejNHUeYUtIfkutmXbuHD1zPr3INRbtvIWb1AeCFo+qhb9Jly4o8l+EYfbbJX3v6gvWnpMIoMD4ps5sZAgadCFzxnDtW/9EO3UqfaJoSZnm+PmG5rdRtz8OwriUoFYF39VFYn/vEsdBdOlv1jeaWMg3EkhupSfb9ff/a2PHw=; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/, AWSALBTGCORS=Uxxfmb3lHmPRejNHUeYUtIfkutmXbuHD1zPr3INRbtvIWb1AeCFo+qhb9Jly4o8l+EYfbbJX3v6gvWnpMIoMD4ps5sZAgadCFzxnDtW/9EO3UqfaJoSZnm+PmG5rdRtz8OwriUoFYF39VFYn/vEsdBdOlv1jeaWMg3EkhupSfb9ff/a2PHw=; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/; SameSite=None; Secure, JSESSIONID=C5C5C4C1C59C4F041524E326C118C4A6; Path=/; Secure; HttpOnly, atlassian.xsrf.token=B14E-GL73-6FKZ-OP3B_3a607d688950fa39757b93fa02be73cf9ca49885_lin; Path=/; Secure, AWSALBAPP-0=AAAAAAAAAAB+eM7eDBFf84O+IW5PVHugNl4hllLR4LLaJPNw1uj5j1UjdRUsbQNcWnSREYnVmyTD0fzgCAdP8r5v6EiaOMm2xju1X6jBEKaSz8BZoBx/U6McarbK9QDj+PMpFXO+ib7gbZ0=; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/, AWSALBAPP-1=_remove_; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/, AWSALBAPP-2=_remove_; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/, AWSALBAPP-3=_remove_; Expires=Mon, 26 Sep 2022 13:54:33 GMT; Path=/', 'X-Seraph-LoginReason': 'OK', 'Strict-Transport-Security': 'max-age=31536000', 'X-AREQUESTID': '834x4614667x2', 'X-ASESSIONID': '5t1ttq', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Mon, 19 Sep 2022 13:54:33 GMT', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Type': 'text/html;charset=UTF-8'}
response text =

 

Suggest an answer

Log in or Sign up to answer