I have to update the status details field using python script.
Status details is a drop-down field having the below values:
None
Production
Staging.
I have to set status details field to Staging using python script.
Can you show an example of what you're already doing?
from jira import JIRAimport urllib3import sysurllib3.disable_warnings()API_token = ''jiraOptions = {'server': 'https://jira.cec.lab.emc.com','verify': False}authedJira = JIRA(jiraOptions, token_auth=API_token,max_retries=0)#exampleticket = sys.argv[1]issue = authedJira.issue(ticket)issue.fields.labels.append(u'deployment_done')issue.update(fields={"labels": issue.fields.labels})
Using this script i can update labels field. but I want to update status details.
You can perform the same step but the status field is a string and not a list, so you can simply just do
ticket = sys.argv[1]issue = authedJira.issue(ticket)issue.fields.status = "Production"issue.update(fields={"status": issue.fields.status})
status is a different field I want to update the "status details" field.
I try with your steps for status field but got error:
Traceback (most recent call last):File "statu_update.py", line 12, in <module>issue.update(fields={"status": issue.fields.status})File "/usr/local/lib/python3.8/dist-packages/jira/resources.py", line 715, in updatesuper().update(async_=async_, jira=jira, notify=notify, fields=data)File "/usr/local/lib/python3.8/dist-packages/jira/resources.py", line 358, in updater = self._session.put(self.self + querystring, data=json.dumps(data))File "/usr/lib/python3/dist-packages/requests/sessions.py", line 593, in putreturn self.request('PUT', url, data=data, **kwargs)File "/usr/local/lib/python3.8/dist-packages/jira/resilientsession.py", line 223, in requestelif raise_on_error(response, **processed_kwargs):File "/usr/local/lib/python3.8/dist-packages/jira/resilientsession.py", line 69, in raise_on_errorraise JIRAError(jira.exceptions.JIRAError: JiraError HTTP 400 url: https://jira.cec.lab.emc.com/rest/api/2/issue/3702014
response headers = {'X-AREQUESTID': '200x1001826x3', 'X-ANODEID': 'jira3n2prd', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': 'sandbox', 'Strict-Transport-Security': 'max-age=31536000', 'Set-Cookie': 'JSESSIONID=jira3n2prd~E85F731D2A10821C07FD337C00158CC8; Path=/; Secure; HttpOnly, atlassian.xsrf.token=B3VN-2ZVW-0G24-EQ32_805930c32b715ccdc407cb50e41b8eb944201570_lin; Path=/; Secure; SameSite=None', 'X-Seraph-LoginReason': 'OK', 'X-ASESSIONID': 'zuyrqz', 'X-AUSERNAME': 'rohild', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '120', 'Date': 'Mon, 19 Sep 2022 07:20:49 GMT', 'Server': 'Apache'}response text = {"errorMessages":[],"errors":{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}}
There's a slight problem with what you're trying to do. Status is not a field, it is a representation of where an issue is in the workflow for the humans to see. It mostly looks like a field but it is not.
You can't just edit a status, you have to transition the issue through the workflow.
I want to update a single select custom field.
1. issue.update(fields={'customfield_11104': [{'value': 'Staging'}]})
2. issue.update(fields={'customfield_11104': 'Staging'})
both above code show error as "response text = {"errorMessages":[],"errors":{"customfield_11104":"Could not find valid 'id' or 'value' in the Parent Option object."}}"
In that single select field, we have the option Staging still it shows the error.
That suggests your field is a cascading select - you will need to set the parent half of the field as well as the child option.
It looks like you're new here. Sign in or register to get started.