Error when searching for issues using JQL enhanced search API, if '&' used in value

Hi,

Recently ran into a problem with searching for issues using the " Search for issues using JQL enhanced search (GET)":

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get

  1. Create a filter which uses this JQL: "Cascading test 1[Select List (cascading)]" = "Foo & Bar"
  2. In a Forge app, get the JQL from a Jira filter using https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-id-get and the jql property from the response (filterResponse.jql)
  3. Calling await requestJira(/rest/api/3/search/jql?jql=${filterResponse.jql}&${parameters}) where parameters contains the wanted fields.
  4. Works fine for a lot of cases but throws an error when the filter has ‘&’ in its strings

So a case where this fails is it filter uses JQL that should match e.g.:

"Cascading test 1[Select List (cascading)]" = "Foo & Bar" where “Foo & Bar” is one of the values for the select list.

In this case we get:

{
    "message": "Error in the JQL Query: The quoted string 'Foo ' has not been completed. (line 1, character 47)",
    "requestUrl": "/rest/api/3/search/jql?jql=\"Cascading test 1[Select List (cascading)]\" = \"Foo & Bar\"&fields=customfield_10020,customfield_10086,issuelinks,issuetype,parent,priority,project,status,summary&&maxResults=250",
    "result": {
        "errorMessages": [
            "Error in the JQL Query: The quoted string 'Foo ' has not been completed. (line 1, character 47)"
        ],
        "errors": {}
    },
    "responseStatus": "400 "
}

Can’t find & in the Special characters.

How can I call the JQL when ‘&’ is part of the query strings to match?

Thanks,
Fredrik

1 Like