Use API to find open or new tickets - doesn't find the right tickets for me

Infos:

Used Zammad version: 4.1.x
Installation method (source, package, …): apt Installation
Operating system: Ubuntu 18.04.6 LTS
Database + version: PostgreSQL 10.18
Elasticsearch version: 7.14.2
Expected behavior:

When using API to retrieve tickets, it would give me tickets list in JSON format with all open or new tickets
Actual behavior:

It shows only three tickets, which are closed
With …/search?query=state_id%3A1%20OR%20state_id%3A2 I get this output: “tickets”:[61,60,12],“tickets_count”:3 …}

In the web I see this:

If I search for the mentioned tickets above, the ticket status is 4 = closed:
{“id”:60,“group_id”:1,“priority_id”:2,“state_id”:4, … }

If I search an open ticket like 88 then I get the right output: {“id”:88,“group_id”:1,“priority_id”:2,“state_id”:2," … }

Steps to reproduce the behavior:

see “Actual behavior” section.
Yes I’m sure this is a bug and no feature request or a general question.

Would be great If someone can help me here!

Greets from Germany
Dominik

Hi @idominiki

Try putting a space between: and your value.

Example:


search?query=state_id%3A%201%20OR%20state_id%3A%202

Greetings
Gijs

Hi Gijs,

thanks for your answer! If I curl
/api/v1/tickets/search?query=state_id%3A%201%20OR%20state_id%3A%202

I get the error “no matches found” :disappointed_relieved:

Greetings
Dominik

Hi @idominiki

I have tried both queries and both work for me:

GET /api/v1/tickets/search?query=state.id:%201%20OR%20state.id:%202&limit=100

GET /api/v1/tickets/search?query=state.name:%20new%20OR%20state.name:%20open&limit=100

Regards,
Gijs

Keep in mind that ID for e.g. states may differ from system to system.
You’ll want to check which IDs are correct in your specific system.

1 Like

Hi @ecomsilio,

thanks again for your help. With

/api/v1/tickets/search?query=state:%20new%20OR%20state:%20open
/api/v1/tickets/search?query=state_id:%202%20OR%20state_id:%201

the request works, but I only get the mentioned three tickets, not all five tickets.

{"tickets":[61,60,12],"tickets_count":3

@MrGeneration thanks for the info, but we use the standard ticket states

[{"id":1,"state_type_id":1,"name":"new","next_state_id":null,"ignore_escalation":false,"default_create":true,"default_follow_up":false,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.039Z","updated_at":"2020-08-15T13:46:30.054Z"},{"id":2,"state_type_id":2,"name":"open","next_state_id":null,"ignore_escalation":false,"default_create":false,"default_follow_up":true,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.051Z","updated_at":"2020-08-15T13:46:30.051Z"},{"id":3,"state_type_id":3,"name":"pending reminder","next_state_id":null,"ignore_escalation":true,"default_create":false,"default_follow_up":false,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.069Z","updated_at":"2020-08-15T13:46:30.069Z"},{"id":4,"state_type_id":5,"name":"closed","next_state_id":null,"ignore_escalation":true,"default_create":false,"default_follow_up":false,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.074Z","updated_at":"2020-08-15T13:46:30.074Z"},{"id":5,"state_type_id":6,"name":"merged","next_state_id":null,"ignore_escalation":true,"default_create":false,"default_follow_up":false,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.087Z","updated_at":"2020-08-15T13:46:30.087Z"},{"id":6,"state_type_id":7,"name":"removed","next_state_id":null,"ignore_escalation":true,"default_create":false,"default_follow_up":false,"note":null,"active":false,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.093Z","updated_at":"2020-08-15T13:46:30.093Z"},{"id":7,"state_type_id":4,"name":"pending close","next_state_id":4,"ignore_escalation":true,"default_create":false,"default_follow_up":false,"note":null,"active":true,"updated_by_id":1,"created_by_id":1,"created_at":"2020-08-15T13:46:30.108Z","updated_at":"2020-08-15T13:46:30.108Z"}]

Any other thoughts on this problem?

Thanks and Greets
Dominik

Hi @idominiki

You might want to check your setting at “settings > overview” to see which status is selected for the view open/offen.

In my case (and I think it is the standard setting) the overview open does not only show new and open tickets but also pending tickets.

So you will need 3 instead of 2 status in your GET request.

Cheers,
Gijs

Hi @ecomsilio

I checked the attributes for the open overview. Here are new and open selected.

Also If I’m search for three ticket attributes, I only get the three mentioned tickets.

/api/v1/tickets/search?query=state:%20new%20OR%20state:%20open%20OR%20state_id:%203

Greets,
Dominik

Hi @idominiki

See if you can scroll. Usually you should see 6 states.

ezgif.com-video-to-gif

Also you are using “state:” and “state_id:”. I am not completely sure if this will work. Try “state.name:” and “state.id:”

Cheers,
Gijs

Hi @ecomsilio,

you’re right, There is also the option pending reminder checked.

If I filter by state.id

/api/v1/tickets/search?query=state.id:%201%20OR%20state.id:%202%20OR%20state.id:%203

I got the following output:

{"tickets":[],"tickets_count":0,"assets":{}}

If I filter by state_id

/api/v1/tickets/search?query=state_id:%201%20OR%20state_id:%202%20OR%20state_id:%203

I got the same three tickets.

{"tickets":[61,60,12],"tickets_count":3,"assets":...}

I don’t know where the issue is.

Thanks again for your support.

Greets
Dominik

Ok, in that case I can’t help you. I can’t look into your Zammad installation and I am not a developer. Maybe @MrGeneration can help.

Cheers,
Gijs

That’s correct because it’s not available in that context.

This would be a correct search if you must - you could also use state.name (see: Advanced Search — Zammad (for Agents) documentation )

So if your overview shows the correct number of tickets but your API search not (expecting you’re using eithert the exact same group permissions or the same user to do so!) then I’d guess your searchindex is off for whatever reason.

You could cross check that by running the exact same search within Zammads UI.
It has to return the same number of tickets.

1 Like

Hi @MrGeneration

Thanks for your answer. The Update to Zammad v5 fixes all problems for me.

Greets
Dominik

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.