Forums

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

Update field on Jira ticket with post request using Python

anne
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 22, 2022
Hi, I'd like to update a field on a Jira ticket using Python, but it did not work. 
I received 200, but it did not update the field.
This (url, body, auth) works with Postman.
Could someone help? 
import requests
import json

name = "abc"

url = f"https://jira.domain.com/rest/api/latest/issue/1343"
body = {"update": {"customfield_11744": [{"set": {"name": name}}]}}
r = requests.put(url, auth=('id','pw'), json=body)

print(r.status_code)

1 answer

0 votes
Sunny Ape
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2022

Hello @anne 

If you read the Python examples provided in the REST API documentation, they show how to use the requests.HTTPBasicAuth module to apply Base64 encoding to the username + token combination in the auth section of the header.

Also, what is the purpose of the letter 'f' before the url in your Python code?

Suggest an answer

Log in or Sign up to answer