REST search with multiple criteria seems to only use first criterion

All

I’m trying to put together a process that uses the REST API to close requests that have been set to a particular status for a number of days, but I’m having trouble limiting the search to both the status and the date range:

$ cat close_aged_requests.sh
#!/bin/bash

if [ ! -e cookiejar.txt ]
then
        curl -d "user=efarayenkay&pass=<password" -c cookiejar.txt https://rt.company.com.au > /dev/null
fi

curl -e https://rt.company.com.au -b cookiejar.txt https://rt.company.com.au/REST/1.0/search/ticket?query="(Status='pendinguser') AND (LastUpdated < '2018-06-22')"

It returned all requests that had ‘pendinguser’ as its status. I assigned one as such this morning but it too appears in this search - indicating to me that it isn’t checking the LastUpdated date.

Am I doing something wrong? Running RT 4.4.1 on OpenBSD 6.1 using OpenBSD’s internal httpd, MariaDB version 10.1.21.

Found it. Seems it doesn’t like any spaces, they need to be either left out or encoded:

curl -e https://rt.company.com.au -b cookiejar.txt https://rt.company.com.au/REST/1.0/search/ticket?query="(Status+=+'pendinguser')+AND+(LastUpdated+<+'2018-06-22')"

In case anyone wants here, here’s my script. Public domain, share and enjoy. Requires curl and bash.

#!/bin/bash

RT_URL=https://rt.company.com.au

if [ ! -e cookiejar.txt ]
then
        curl -d "user=rtuser&pass=rtpass" -c cookiejar.txt $RT_URL > /dev/null
fi

NEWLINE="
"

curl -e $RT_URL -b cookiejar.txt $RT_URL/REST/1.0/search/ticket?query="(Status+=+'pendinguser')+AND+(LastUpdated+<+'2018-06-22')" | cut -d: -f 1 | while read id
do
        case $id in
                ''|[^0-9]*) ;;
                *)
                        echo closing $id
                        curl --data-urlencode "content=id: $id${NEWLINE}Action: comment${NEWLINE}Text: Closing aged request" -e $RT_URL -b cookiejar.txt $RT_URL/REST/1.0/ticket/$id/comment
                        curl --data-urlencode "content=id: $id${NEWLINE}Status: resolved" -e $RT_URL -b cookiejar.txt $RT_URL/REST/1.0/ticket/$id/edit
                ;;
        esac
done