JQL saved word and Error message

Tal Erez December 4, 2019

Hello,

i'm trying to use Jira's REST api to get an issue key using its name (summary).

My get request looks like this so far:

var getUrl = {

url : "https://" + process.env.JIRA_USERNAME + ":" + process.env.JIRA_PASSWORD + "@" + process.env.JIRA_BASE_URL + '/rest/api/2/search?jql=Summary~"\"'

+ testCaseID + '\""',

method: "GET"

};

The testCaseID is the changing summary variable , and some of the summaries contain saved JQL words, therefore I receive the following error:

""Error in the JQL Query: 'Access' is a reserved JQL word. You must surround it in quotation marks to use it in a query."

 

I tried to add quotation marks and save the testCaseID as a new variable

var testCase = '"'+TestCaseID+'"'

and add it where the testCaseID was, but then I receive following error:

["Error in the JQL Query: Expecting either 'OR' or 'AND' but got <testname>"

 

How can I solve this issue?

1 answer

0 votes
Warren
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.
December 4, 2019

Hi @Tal Erez 

You haven't specified which version of Jira you're using (cloud or server), although I don't think it should make any difference. You also haven't specified which programming language you're using - looks a bit like Java?

When I pass this query to the API using C#, it returns successfully

 string query = @"/rest/api/3/search?jql=project=DS and summary~""Access""";

In C#, using 2 sets of double quotes leaves the string in double quotes

Tal Erez December 5, 2019

Hello @Warren 

I solved the problem by adding another backslash to the url. "\\" + TestCaseID  + \\""

solved it eventually.

I use Javascript. Thanks for the help :)

Suggest an answer

Log in or Sign up to answer