Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Jira API throwing 400 error on Python script

I'm trying to update the description field using the API but I keep getting a 400 error. The auth is correct as I can use GET for projects, issues, comments, etc. Here's the function where I make the PUT call: 

def updateTicket(dictData):

strKey = dictData["key"]
dictFields = {"fields": {"description": "test"}}

strURL = "" + strKey

response = requests.put(strURL, json="{'fields': {'description': 'test'}}", headers=myHeader)


And the output is: 

Bad Request

I'm not new to programming but fairly new to Python. I did see some other questions in here with similar issues where the culprit was the Requests module. It automatically does a json.dumps() call on json data passed and the OP was already doing that in his code so the JSON was malformed. 

I don't believe that is my issue as  I am hardcoding the JSON string in the request call. 

Any help would be appreciated 

1 answer

Check and make sure its not requiring ADF formatting:

Note that the descriptionenvironment, and any textarea type custom fields (multi-line text fields) take Atlassian Document Format content. Single line custom fields (textfield) accept a string and don't handle Atlassian Document Format content.

That seems like a lot of overkill if someone wants to just add some simple text. Be nice if there was an option to choose between some rich text and plain text formatting. 

I agree!


As a quick & dirty troubleshoot, have you tried formatting the payload data according to these Rest Examples in links below? You be able to test with the Curl examples provided if you have a Mac or Linux box:

Create Issue:

Edit Issues:

That's about all I can think of. 

@Tommy Augustine 

The solution worked. I got wrapped up in other stuff and forgot to respond. The formatting requirements is not a huge deal.

Really all I am doing is cleaning up some poorly designed tickets. Someone designed this board and decided it would be a good idea to have a custom field for what is essentially a description and so users sometimes used the description field, sometimes the custom field, sometimes both, sometimes just decided to put stuff in the comments instead. 

Anyway, it worked, thanks for the pointing me in the right direction. Still think there should be a lighter update option.

Like Tommy Augustine likes this

Suggest an answer

Log in or Sign up to answer
Site Admin

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you