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 = "https://kargo1.atlassian.net/rest/api/3/issue/" + strKey
response = requests.put(strURL, json="{'fields': {'description': 'test'}}", headers=myHeader)
print(response.reason)
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
Check and make sure its not requiring ADF formatting:
Note that the description
, environment
, 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.
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put
https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-create-issue-7897248/
Edit Issues:
https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-edit-issues-6291632/
That's about all I can think of.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think V2 of the api can help because it doesn't work with ADF formatting
https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all
Morgan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.