Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a custom field value in JIRA using Python and Rest API?

Monica Muñoz
Contributor
July 18, 2023

Hi community,

I need to update the following jira property in my tickets:

"fields" : {"customfield_15035": [{"prop1": "xxxx", "prop2": "yyyy", "prop3": "zzzz"}]}

I tried to use the documentation code for Python, but I have not been able to adapt it.

Can someone please advice? How to change the customer field?, via payload?

Thanks

import requests

from requests.auth import HTTPBasicAuth

import json url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/properties/{propertyKey}"

auth = HTTPBasicAuth("email@example.com", "<api_token>")

headers = { "Accept": "application/json", "Content-Type": "application/json" }

payload = json.dumps( {} )

response = requests.request( "PUT", url, data=payload, headers=headers, auth=auth )

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 

2 answers

1 accepted

1 vote
Answer accepted
Monica Muñoz
Contributor
July 18, 2023

Hi,

I was able to update my custom_field with the following code:

import requests
import json
from requests.auth import HTTPBasicAuth


url = "https://your-domain.atlassian.net/rest/api/2/issue/{issue_key}"

issue_key = "TEST-55"

auth = HTTPBasicAuth(user, passw)


payload = {
"fields": {
"customfield_15035": [{"prop1":"xxxxx","prop2":"yyyyy","prop3":"zzzzz"}]
}
}


json_payload = json.dumps(payload)

headers = {
"Content-Type": "application/json"
}


response = requests.put(url.format(issue_key=issue_key), data=json_payload, headers=headers, auth=auth)

print(response.status_code)
0 votes
Mohamed Benziane
Community Champion
July 18, 2023

What kind of customfield are you trying to update ?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events