Reputation: 2206
I want to know how to get list of all active jira issues through rest api. Once when i get the list I am planning on using si/jira.issueviews:issue-xml feature in the uri to download all issues in xml format. But I do not have the list of all the issues. I have googled and only came up with answers that has to do with getting issues under a specific project.
Upvotes: 2
Views: 983
Reputation:
This is how I do a search using cURL and the REST API in PHP:
$url = "http://YOUR_SERVER_URL_AND_PORT/rest/api/2/search";
$data = array("jql" => "status not in (Closed, Resolved, Done)","startAt" => 0,"maxResults" => 200);
$httpHeader = array(
'Accept: application/json',
'Content-Type: application/json'
);
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "USER_NAME:USER_PASS");
$result = curl_exec($ch);
$ch_error = curl_error($ch);
if ($ch_error == '')
$out = $result;
else
$out = json_encode(array('error' => $ch_error));
}catch(Exception $e){
$out = json_encode(array('error' => $e->getMessage()));
}
curl_close($ch);
You need to change YOUR_SERVER_URL_AND_PORT, USER_NAME and USER_PASS with your own information.
NOTE: the previous REST query will only return issues that you are allowed to see. If you need to see ALL issues, you need to provide Jira Admin credentials in your cURL config.
Upvotes: 1