jira-python search_issues encodes jql string twice

I'm using jira-python library 1.0.4, and can't get the following issue search to work.

jira.search_issues(jql_str="project=ABC")

It is throwing an exception:

    jira.exceptions.JIRAError: JiraError HTTP 400 url: https://jira.my.com/rest/api/2/searchjql=project%253DABC&validateQuery=True&startAt=0&maxResults=50

    response text = {"errorMessages":["Error in the JQL Query: The character '%' is a reserved JQL character. You must enclose it in a string or use the escape '\\u0025' instead. (line 1, character 8)"],"errors":{}}

It looks like 'project=ABC' is getting encoded twice, and I don't understand why and how to prevent it.  '=' -> '%25' -> '%253D'.  The url should be:

https://jira.my.com/rest/api/2/search?jql=project%3DABC&validateQuery=True&startAt=0&maxResults=50

Thanks for any help.

3 answers

1 accepted

Perhaps the double-encoding problem is somehow caused by the HTTP -> HTTPS redirect?

0 vote

Can you try upgrading to 1.0.7 (which is the latest version available via pypi)?

 

I just tried to run this myself and ran into no issues, on both 1.0.3 and 1.0.7.

from jira import JIRA
un = ''
pwd = ''
server = ''
jira = JIRA(basic_auth=(un, pwd), options={'server': server})
issues = jira.search_issues(jql_str="project=TBT")
print len(issues)

That returns a valid count of issues for the queried project (in my case TBT project)

Jeff,

Thanks so much.   Just having your sample script helped.   It was a careless mistake of using http on the server, instead of https, that caused the issue, though the symptom was strange.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you