Eugen
1
Infos:
Used Zammad version: 6.3.1-1727329238.012f549d.bullseye
Used Zammad installation type:source
Operating system: Ubuntu
Expected behavior:
- The filtering of tickets by group_id should work correctly, both via the API and in the advanced search within the UI.
- The API query using group_id should return all relevant tickets.
Actual behavior:
- The API query for group_id returns either no results.
- The advanced search in the UI with
group_id:43
does not work properly.
Steps to reproduce the behavior:
- Execute an API call:
curl -u 'email:password' -X GET "https://our-zammad-instance/api/v1/tickets/search?query=group_id:43"
or
Powershell
Invoke-RestMethod -Uri “https://our-zammad-instance/api/v1/tickets/search?query=group.id.keyword=43” -Method Get -Headers $Headers -ContentType “application/json; charset=utf-8”
…or {query=group_id=43} or {query=group_id:43}
- Check the results → No ticket display.
Please provide guidance on whether this is a known issue or if there is an alternative recommended method.
Thank you!
If the group id is correct then the curl looks fine. Maybe your user has insufficient permissions on that group?
Eugen
3
I executed it like this:
Invoke-WebRequest -Uri $URL -Headers $Headers -Method Get
But how can I retrieve all results and not just 50?
And how can I filter only for open and new tickets?
$Response.Content | ConvertFrom-Json
tickets tickets_count assets
{699242, 699354, 698471, 696965…} 50 @{Ticket=; Group=; User=; Role=; Organization=}
Eugen
4
And when I try to sort using:
https://tt.c-rown.it/api/v1/tickets/search?query=group_id:43&order_by=created_at&sort=desc
I get a 500 error.
You have to use pagination on Zammads API as mentioned in our documentation:
https://docs.zammad.org/en/latest/api/intro.html#pagination
As for the sorting issue, you’re supposed to use sort**_by**
Eugen
6
Thanks very match
$EncodedAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$Username`:$Password"))
$Headers = @{
"Authorization" = "Basic $EncodedAuth"
}
$URL = "https://zammad/api/v1/tickets/search?query=group_id:43&order_by=desc&sort_by=created_at"
$Response = Invoke-WebRequest -Uri $URL -Headers $Headers -Method Get
# === JSON-Inhalt extrahieren und in ein PowerShell-Objekt umwandeln ===
$TicketsData = $Response.Content | ConvertFrom-Json
try {
$Response = Invoke-RestMethod -Uri $URL -Headers $Headers -Method Get
$TicketIDs = $Response.tickets
$TicketAssets = $Response.assets.Ticket
} catch {
Write-Output "❌ Fehler beim Abrufen der Ticket-Daten: $_"
return
}
$TicketDetails = @()
foreach ($TicketID in $TicketIDs) {
#pause
if ($TicketAssets.$TicketID) {
$Ticket = $TicketAssets.$TicketID
$TicketDetails += [PSCustomObject]@{
ID = $Ticket.id
Number = $Ticket.number
Title = $Ticket.title
StateID = $Ticket.state_id
CreatedAt = $Ticket.created_at
UpdatedAt = $Ticket.updated_at
}
}
}
# === Ticket-Status: "new" und "open" (StateID 1 & 2) ===
$NewOpenTickets = $TicketDetails | Where-Object { $_.StateID -in @(1,2) }
# === Tickets nach Erstellungsdatum sortieren ===
$SortedTickets = $NewOpenTickets | Sort-Object CreatedAt -Descending
# === Ergebnis ausgeben ===
Write-Output "Anzahl der letzten 40 'new' und 'open' Tickets: $($SortedTickets.Count)"
$SortedTickets | Format-Table ID, Number, Title, CreatedAt, UpdatedAt -AutoSize
system
Closed
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.