Forums

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

Problems with Rest API 3

michael seward February 14, 2024

I am having an issue looking up issues by a JQL text, i run this code every morning, nothing has changed, its worked perfect before, but now this morning it is returning the error: 

 

{'errorMessages': ["Error in the JQL Query: Expecting either 'OR' or 'AND' but got ','. (line 1, character 18)"], 'errors': {}}

 

 

the api is below. Again this was working fine before, then all of a sudden it stopped working this morning. I have texted other API calls such as creating a ticket, and it works fine, so i know the permissions are fine. But for some reason im having a really hard time figuring this out. If anyone can shed some light i would greatly appreciate it! Thanks again:

url = "https://*****.atlassian.net/rest/api/3/search/?jql=text ~" + *****

headers = {
"Accept": "application/json",
}

query = {'jql': '"text ~"'}

# GET API call
response = requests.request(
"GET",
url,
headers=headers,
params=query,
auth=auth
)


2 answers

0 votes
michael seward February 15, 2024

so i just fixed it, but i had to change this:  

query = {'jql': '"text ~"'

 

to this:

 

payload = ""


and at the bottum under response i had to change the following:
params=query,

to:

data=payload








not even sure why this worked exactly, but it did fix the issue i was having. if you can shed some light on the explanation so i understand this better going forward that would be great, if not i completely understand as im still trying to find out why exactly this worked.


0 votes
Bill Sheboy
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.
February 14, 2024

Hi @michael seward 

That error seems to indicate whatever text you are trying to match with the CONTAINS ~ operator ends the expression (possibly due to an unescaped quotation mark) and so the JQL parser is expecting either AND or OR to continue.

I recommend looking at your specific search text to determine if that is the case.  Perhaps the expression needs to be URL encoded to work.

Kind regards,
Bill

michael seward February 14, 2024

Bill can you provide an example of how i should change the code? and im confused as to why it worked everyday up until this morning. can you send me exactly what you would change or change it to?

Bill Sheboy
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.
February 14, 2024

I am unclear what to suggest due to what is not shown.  How about this: what text are you searching for in issues?  That may help indicate why this code started failing.

The CONTAINS operator only works with some fields and has some limitations on what can be searched for: https://support.atlassian.com/jira-software-cloud/docs/jql-operators/#CONTAINS----

Perhaps whatever is being passed to it now for the search is causing the failure.  Certainly the following you are showing does not work for a search, as it is incomplete:

text ~ 

There must be something after that tilde.

michael seward February 15, 2024

Thank you for the response. yes I am bassing a series of letters and numbers. that pertain to a specific customer in our system, here is an example:



5KJ4B42XX60


please let me know if this clarifies it or if you can recommend something different, i'm still scratching my head on this one as i said before it worked fine, so i'm very confused.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events