I'm trying to search for issues using trivial JQL, limiting the response to a small subset of fields using the POST variety of Jira Server's 'search' REST API. Lifting HTTP and data parameters from Atlassian's published search API examples , the response is ignoring the "jql", "maxresults", and "fields" data args and returns all issues in the db.
Python script:
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json
url = "http://jira.companyX.com/rest/api/2/search"
auth = HTTPBasicAuth("user_name", "user_password")
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps( {"jql":"project=DC","startAt":0,"maxResults":2,"fields":["id","key"]} )
response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Rather than scope the results to the JQL filter and maxResults, the response contains issues from all projects and all values for all fields in the db including custom fields, and terminates with:
"maxResults": 50,
"startAt": 0,
"total": 123215
The same command using CURL:
curl |
-D- |
-L |
-X POST |
-H "Authorization: Basic user_creds_in_base64" |
-H "Accept: application/json" |
-H "Content-Type: application/json" |
--data '{"jql":"project=DC","startAt":0,"maxResults":2,"fields":["id","key"]}' |
http://jira.companyX.com/rest/api/2/search
returns
{"errorMessages":["No content to map to Object due to end of input"]}Anyone have an idea what might be amiss? Thanks!