I have problem with update jira custom field…
This is my python script:
import requests
from requests.auth import HTTPBasicAuth
import json
JiraApiUrl = "https://<jira_url>/rest/api/2/issue/<task_number>"
auth = HTTPBasicAuth("<username>", "<password>")
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
update_body = {
"fields": {
"customfield_11100": ["Simple text"]
}
}
response = requests.put(JiraApiUrl, json=update_body, headers=headers, auth=auth)
print("Response Status Code:", response.status_code)
print("Response Content:", response.text)
If i use this script i have this error:
Response Status Code: 400 Response Content: {"errorMessages":[],"errors":{"customfield_11100":"Could not find an existing environment with that id: Simple text"}}
Manually I can select the value I need. If I manually select the value I need and click “View page source” in google chrome I can see that my value has an ID of “6”:
<div class="wrap">
<strong title="Detected in" class="name">
<label for="customfield_11100">Detected in:</label>
</strong>
<div id="customfield_11100-val" class="value type-holydev_environment_customfield" data-fieldtype="holydev_environment_customfield" data-fieldtypecompletekey="com.holydev.env.plugin.jira-holydev-env-plugin:holydev_environment_customfield">
<a title='Details of Simple text' style="text-decoration: none;" class="environment-customfield-chip" data-environment="{"id":6,"name":"Simple text","url":"https://<example_url>/","application":{"id":5,"name":"Display Devices"},"category":{"id":1,"name":"Dev"},"environmentPermissionScheme":{"id":2,"name":"<SPACE> Environment Permission Scheme"},"panelSchemeId":1,"deployment":{"id":18,"environmentId":6,"deployer":"guerragi","deployedItem":1716213300000,"categoryId":1,"categoryName":"Dev","applicationId":5,"applicationName":"Simple text","buildNumber":"2024.10.17.195.20240101.1","attributes":{}},"watched":false}">
<span class='aui-lozenge ' data-id='6' id='cf-customfield_11100-env-id-6'>Simple text</span>
If I substitute the ID number in my script instead of the text, the script works and I get a response of 204.
Section where i want put my value is “Detected in” Golive
This custom field was generated using the GoLive plugin. On the spot “Simple text” I substitute environment. Since in the future I may have many different types of environments, I would like the script to work with text and not with ID, because in my opinion it is not possible to first get the ID and then run the script.
Any ideas ? Please help
I try to use python script and jira rest api for resolve my issue