I'm trying to perform a query
via the Zendesk Search API that compares two fields. E.g. I want to get all tickets where created_at
is equal to updated_at
.
This syntax is accepted, but the result is not correct query=type:ticket created_at:(updated_at)
.
Are such predicates supported by the Zendesk Search API? If not - are there other endpoints, which can provide me the desired outcome?
I can't see anything that supports this syntax in the search reference. You would have to query tickets in your preferred time range, or of all time, and assert if the creation and update time indeed match. Here is a sample code on how you do it in python using a Zendesk API wrapper called Zenpy:
from dotenv import load_dotenv
from zenpy import Zenpy
from os import environ
load_dotenv()
def main():
zenpy_client = Zenpy(
subdomain=environ["SUBDOMAIN"],
email=environ["EMAIL"],
token=environ["API_TOKEN"],
)
tickets = zenpy_client.tickets.incremental(start_time=1)
for ticket in tickets:
if ticket.created_at == ticket.updated_at:
print(ticket)
if __name__ == "__main__":
main()
The code will print the ticket id of any ticket that had no update since creation.