1

Iam using the Jira Rest Api to read data from our Jira-System. In most cases this works fine but i have a problem if & is in query.

I try following query:

http://jira-test.meinServer.de/rest/api/2/search?jql=labels="F&E"

which produces this error message:

"Fehler in der JQL-Abfrage: Die Zeichenfolge mit Anführungszeichen 'F' wurde nicht abgeschlossen. (Zeile 1, Zeichen 8)"

in englisch: "Error in JQL-Syntax: The string with 'F' isn't closed. (line 1, char 8)"

I found that & is the problem. But i can't find some workaround or documentation how to escape this.

Someone got a solution for this?

Sebi
  • 3,879
  • 2
  • 35
  • 62

1 Answers1

3

You didn't encode your query string properly. Try: http://jira-test.meinServer.de/rest/api/2/search?jql=labels%3D%22F%26E%22

Reference

The part of an URI caught between ? and # characters is called the query string (the part after # is called fragment). Often the query is a sequence of key–value pairs (laid out as {key}={value}) separated with the & character.

If you analyze the URL you provided and split it by & you'll see that in fact you are passing two parameters in your query string:

  • parameter jql with a value of labels="F
  • parameter E" with no value

The second parameter is ignored as this particular REST endpoint doesn't expect it. As you can now clearly see you are passing a malformed JQL in your URL. It's because you want to include a special character in your JQL query.

To make it possible you have to properly encode your JQL. This is a common problem and most of the platforms provide tools to do that. Here are examples for JavaScript, C# and Java.

Click here to learn more about the query strings.

jannis
  • 4,843
  • 1
  • 23
  • 53