It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Python Requests - POST request to change status

I am using python requests to update the status of a Jira ticket. Below is the code - 


headers = {"Content-type": "application/json",'Accept' : 'application/json'}

body = {"update": {"comment": [{"add": {"body": "The ticket is resolved"}}]},"transition": {"id":id }}

url = f"{key}/transitions"

r =,data=body,auth=HTTPBasicAuth('user', 'password'),headers=headers)


the value of key is correct. The value of transition id is correct. When I trigger the same post request through postman, Jira gets updated. However when executing it through python script, I get the following error - 


{"errorMessages":["Unexpected character ('u' (code 117)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@3bb9f13b; line: 1, column: 2]"]}


Please let me know, how to resolve the error.

2 answers

1 accepted

1 vote
Answer accepted

The issue has been resolved. 

The request documentation says - 

Instead of encoding the dict yourself, you can also pass it directly using the json parameter (added in version 2.4.2) and it will be encoded automatically:

I changed the post request. instead of data=body, I made it json=body


 r =,json=body,auth=HTTPBasicAuth('XXX', 'YYY'),headers=headers)

This solved my problem, thank you.

The above hint solved my issue too :-)Thank you

0 votes
Warren Community Leader Nov 13, 2018

Hi Tushar

I believe that you need a closing bracket and comma before comment, then remove the extra bracket before transition, so 

body = {"update":{}, "comment":[{ "add": { "body": "The ticket is resolved"}}],"transition": { "id": id  }}

is valid JSON and is a similar structure to what I use

@Warren If I use your syntax, I am still getting the error. The error message is -


"Unexpected character ('c' (code 99)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@66c7db85; line: 1, column: 2]"

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

365 views 1 3
Join discussion

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