Search code examples
pythonapijiracustom-fields

Adding values to Jira Issue picker custom field using python


I'm trying to add some values to a issue picker custom field in Jira, using Python.

I'm getting <Response [405]> and no value has been added.

The code I'm running:

import requests
import json

key = "TES-78"
Cus1 = "customer_name"

url = "https://**Company_Name**/rest/api/2/issue/"+key

headers = {
 'Authorization': 'Basic **************',
 'Content-Type': 'application/json',
 'Cookie': 'JSESSIONID=***; atlassian.xsrf.token=***'
}

payload = json.dumps({

"update": {
   "customfield_12301": [{"add": {"summary": Cus1}}]
}
})

response = requests.request("POST", url, headers=headers, data=payload)
print(response)

anyone knows how can I add values to the issue picker field? Thanks!


Solution

  • HTTP 405 is "Method Not Allowed": Mozilla Developer link

    So, the server just telling you that you should use different HTTP method.

    For updating a custom field value in Jira, you should use "PUT" method instead of "POST".

    You can find details from this Atlassian Developer page.