I'm trying to add new values to a multiple select custom field. I'm getting 401 response. The code taken from Atlassian documentation . Anyone knows why? maybe it is something with the authentication method?
import requests
from requests.auth import HTTPBasicAuth
import json
customers_id = "10163"
contextId = "int64"
url = "https://MY_DOMAIN.atlassian.net/rest/api/3/field/{customers_id}/context/{contextId}/option"
auth = HTTPBasicAuth("MY_EMAIL", "MY_API_TOKEN")
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps( {
"options": [
{
"disabled": "false",
"value": "Manhattan"
},
{
"disabled": "false",
"value": "The Electric City"
}
]
} )
response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",",": ")))
You have "int64" which is a string, it should be 12345 or whatever your contextID is.
There might be something else going on here also: 401 is Returned if the authentication credentials are incorrect or missing. Is this your own Jira Cloud instance or one managed by someone else as you need the following permissions - Permissions required: Administer Jira global permission. So you may not have sufficient rights to make this call?