Hi! I am newbie here!
I am trying to get issues by passing some parameters using JQL.
First, I am building normal string for jql
e.g jqlExpr:::::::: project=Jira&fields=id,key,project,assignee,description,summary,status,priority,reporter,created,updated,issuetype,subtasks&maxResults=-1&assignee=abc
After encoding it with java method : #[java.net.URLEncoder.encode(flowVars.jqlExpr)]
also i am setting the encoding as 'ISO 10646/Unicode(UTF-8)'
I am passing it the request call as:
https://<host>/rest/api/2/search?jql=project%3DJira%26fields%3Did%2Ckey%2Cproject%2Cassignee%2Cdescription%2Csummary%2Cstatus%2Cpriority%2Creporter%2Ccreated%2Cupdated%2Cissuetype%2Csubtasks%26maxResults%3D-1%26assignee%3Dabc
Error message i am getting :
Error: {
"errorMessages": [
"Error in the JQL Query: Expecting either 'OR' or 'AND' but got ','. (line 1, character 21)"
],
"errors": {}
}
I am not able to understand what's going wrong and how can I resolve?
I appreciate your response.Thanks!
Hi Anuja
assignee=abc is part of the jql, but you've got it as a parameter being passed to the API. Try
jql=project=Jira AND assignee=abc&fields=id,key,project,assignee,description,summary,status,priority,reporter,created,updated,issuetype,subtasks&maxResults=-1
If you still get an error, try copying just the JQL bit (i.e. everything after jql= up to and excluding the first &) into a Jira query and see if there are any errors
Hello Warren,
Thanks a lot!
the best answer! it did not only just resolve the error but also helpful in a way to connect the dots here.
I tried to use JIRA's UI to search issues to know url--> concluded that it should be encoded but JIRA's UI allowed only these two Fields 'project' and 'assignee' in advanced search issue text field, wondering why it wont allow 'fields=id,key..etc'
Now i got what JQL is!
so no need to do encoding in this case!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Warren,
The same query is not working for me. It gives me a project that does not exist even though it existed. I am the admin of this Jira account, but still not able to retrieve the data. I am using basic authentication. The same query is working fine from Jira UI. Can you please help me out?
Here is the output:
<Response [400]>
{
"errorMessages": [
"The value 'XXX' does not exist for the field 'project'."
],
"warningMessages": []
}
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kondal A
To help me help you, could you please give the full API call that you're trying to use? (Anonymise your project name if you want). Also, have you been able to successfully run other API calls?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Warren
Thank you for your quick response. No, I did not try other API calls, I just tried the below API as I need to try jql and search for the project data.
https://my-test.atlassian.net/rest/api/2/search?jql=project=TEST
response = requests.request(
'GET',
url,
headers=headers,
auth=auth
)
print(response)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
The above API returns the project not exist error.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kondal A
So just to confirm, you've typed
project=TEST
into the filter section within Jira and it returns something?
If so, try running the API without the jql for now, i.e.
https://my-test.atlassian.net/rest/api/2/search
and then try
https://my-test.atlassian.net/rest/api/2/search?jql=key=ABC-123
where ABC-123 is the key of an issue that you know you can view within Jira.
Let me know what happens with those.
Another question, you said you're using basic auth, can you explain exactly what you're using for that? Email address? Password? API token?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Warren,
Sorry for the late reply. I am able to retrieve the data, I was using wrong username. In the basic auth I just used username and API token.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
fields= is not part of JQL, it is what the API uses to know which fields to report on. The equivalent in the Jira issues screen is the Columns dropdown where you choose which fields (columns) to show
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.