Search for tickets after a certain data in a given queue

In the REST 1.0 interface, I can Get a list of all the Ticket IDs for this Queue using:

I need to restrict this further, to tickets created after a certain date by checking against the Create field. Nothing that I’ve seen in the forum or in the documentation covers this.

We have the REST 2.0 module installed, so we’re not limited to only what REST 1.0 can do. It’s crucial to limit the output as described because we’ll run a function against each ticketID to determine if it meets certain criteria and if so, extract certain data from it.

This must be done in the context of a script (we write ours in PHP) so that the search can be done nightly via a cron job.

The current PHP function looks like this:

function searchQueue($token, $queue, $tsStart) {
$serviceURL = “https://{SERVER}/rt/REST/1.0/search/ticket?query=Queue=’$queue’”;
$ch = curl_init($serviceURL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(“Authorization: token $token”));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$response = preg_replace(’/RT/4.4.2 200 Ok\n\n/’, ‘’, $response);
$response = preg_replace(’/[:\s].*.[\n]/’, ‘,’ , $response);
$list = explode(’,’,$response);
return ($list);

Thanks in advance!

“You can pass any query from the query builder in as the query parameter. You would just need to go to search → new search and build the query you want to do, then click on advanced (top right) to grab the query text.”

Once tou have your query:

$query=urlencode(“Created > ‘2018-12-11’ AND Queue = ‘something’”);
$serviceURL = “https://{SERVER}/rt/REST/1.0/search/ticket?query=”.$query;

I hope this helps someone else.

Thanks to Nathan from