Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Parse and validate JQL with the Jira REST API
POST /rest/api/3/jql/parse takes an array of queries and a validation mode and returns one result per query. A valid query comes back as a structure of clauses. An invalid one comes back inside the 200 response with an errors array, so the HTTP status does not tell you whether the JQL was good.
Endpoints
| Method | Path | What it does |
|---|---|---|
POST | /rest/api/3/jql/parse | Parses and validates JQL queries. |
GET | /rest/api/3/jql/autocompletedata | Lists the field names, functions and reserved words the parser knows. |
Examples
POST /rest/api/3/jql/parse
Parses a valid and an invalid query in one call with validation=strict.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"queries": [
"project = WEB AND status = Done",
"project = "
]
}' \
'https://your-domain.atlassian.net/rest/api/3/jql/parse?validation=strict'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/jql/parse?validation=strict',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'validation': 'strict'},
json={'queries': ['project = WEB AND status = Done', 'project = ']},
)
print(r.status_code, r.text)Response: HTTP 200
{
"queries": [
{
"query": "project = WEB AND status = Done",
"structure": {
"where": {
"clauses": [
{
"field": {
"name": "project",
"encodedName": "project"
},
"operator": "=",
"operand": {
"value": "WEB",
"encodedValue": "WEB"
}
},
{
"field": {
"name": "status",
"encodedName": "status"
},
"operator": "=",
"operand": {
"value": "Done",
"encodedValue": "Done"
}
}
],
"operator": "and"
}
}
},
{
"query": "project = ",
"errors": [
"Error in JQL Query: Expecting either a value, list or function before the end of the query."
],
"warnings": []
}
]
}Response headers
X-Ratelimit-Limit: 200Sent to Atlassian Cloud on .
POST /rest/api/3/search/jql
The same broken JQL sent to the search endpoint is a 400 with the same message text.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"jql": "project = WEB AND status = ",
"maxResults": 1
}' \
'https://your-domain.atlassian.net/rest/api/3/search/jql'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/search/jql',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'jql': 'project = WEB AND status = ', 'maxResults': 1},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [
"Error in JQL Query: Expecting either a value, list or function before the end of the query."
],
"errors": {}
}Sent to Atlassian Cloud on .
GET /rest/api/3/jql/autocompletedata
The reference data behind the parser, with the field names and operators it accepts.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/jql/autocompletedata'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/jql/autocompletedata',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"visibleFieldNames": [
{
"value": "\"[CHART] Date of First Response\"",
"displayName": "[CHART] Date of First Response - cf[10026]",
"orderable": "true",
"searchable": "true",
"operators": [
"=",
"!=",
"in",
"not in",
"is",
"is not",
"<",
"<=",
">",
">="
],
"types": [
"java.util.Date"
]
},
{
"value": "\"[CHART] Time in Status\"",
"displayName": "[CHART] Time in Status - cf[10027]",
"orderable": "true",
"searchable": "true",
"operators": [
"~",
"!~",
"is",
"is not"
],
"types": [
"java.lang.String"
]
}
]
}Sent to Atlassian Cloud on .
How it behaves
- A valid query returned structure.where with a clauses array. Each clause has field, operator and operand, and the combining operator is and.
- The invalid query "project = " returned an object with query, an errors array and an empty warnings array, and no structure key.
- The HTTP status was 200 although one of the two queries was invalid.
- The error text matches what the search endpoint returns for the same mistake, only as a 400 there.
Pitfalls
- Check each result for errors instead of checking the status. A 200 can contain failed queries.
- The validation parameter is required. The spec lists strict, warn and none. With strict a failed query returns no structure, and with warn a correctly formed one keeps it.
- Validation runs in the context of the current user, as the spec states, so run it with the account that will run the search.
Questions and answers
Does parse return 400 for bad JQL?
Not in the run above. The invalid query came back inside a 200 response with an errors array.