You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-12-09 06:56:24

little_devil
Member
Registered: 2024-12-09
Posts: 7

How to get tickets for a certain group with REST API?

I've created 3 test groups on GLPI. Then - 2 tickets for each group - I specified Requester field, when created tickets.

Now I want to get tickets for a certain group with REST API.

Let's say I make such request:

.../apirest.php/Group/2/Ticket

No errors. But I get all tickets.
The same if i do:

.../apirest.php/Group/1/Ticket

Data for a ticket:
{
        "id": 7,
        "entities_id": 0,
        "name": "Ticket 2 Group 3",
        "date": "2024-12-01 18:58:49",
        "closedate": null,
        "solvedate": null,
        "takeintoaccountdate": "2024-12-01 18:58:49",
        "date_mod": "2024-12-01 18:58:49",
        "users_id_lastupdater": 7,
        "status": 2,
        "users_id_recipient": 7,
        "requesttypes_id": 1,
        "content": "<p>Ticket 2 Group 3</p>",
        "urgency": 3,
        "impact": 3,
        "priority": 3,
        "itilcategories_id": 0,
        "type": 1,
        "global_validation": 1,
        "slas_id_ttr": 0,
        "slas_id_tto": 0,
        "slalevels_id_ttr": 0,
        "time_to_resolve": null,
        "time_to_own": null,
        "begin_waiting_date": null,
        "sla_waiting_duration": 0,
        "ola_waiting_duration": 0,
        "olas_id_tto": 0,
        "olas_id_ttr": 0,
        "olalevels_id_ttr": 0,
        "ola_tto_begin_date": null,
        "ola_ttr_begin_date": null,
        "internal_time_to_resolve": null,
        "internal_time_to_own": null,
        "waiting_duration": 0,
        "close_delay_stat": 0,
        "solve_delay_stat": 0,
        "takeintoaccount_delay_stat": 1,
        "actiontime": 0,
        "is_deleted": 0,
        "locations_id": 0,
        "validation_percent": 0,
        "date_creation": "2024-12-01 18:58:49"
    }

The mem is that I thought like: maybe there's an attribute in data that connects tickets and groups, so I could do filtering with "searchText" parameter. But no! There's no attribute. Only users_id_recipient and users_id_lastupdater which are all the same. Is there a solution for it?

Offline

#2 2024-12-09 10:43:32

cconard96
Moderator
Registered: 2018-07-31
Posts: 3,226
Website

Re: How to get tickets for a certain group with REST API?

/apirest.php/Group/2/Ticket is not going to work because Ticket isn't a child type. The current API sees the "Ticket" part at the end and ignores everything before it.

You should be using "/apirest.php/search/Ticket" (/apirest.php#content-search-items has the documentation for it).
Search option ID 71 is the requester group option.


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2024-12-09 10:45:01

cconard96
Moderator
Registered: 2018-07-31
Posts: 3,226
Website

Re: How to get tickets for a certain group with REST API?

As a side-note, a new API will be coming in GLPI 11 which is more user friendly and not as low-level so confusion and unexpected behavior with paths like this shouldn't be an issue. The current API will remain as a "legacy API".

https://github.com/glpi-project/glpi/pull/12221


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#4 2024-12-09 10:53:17

little_devil
Member
Registered: 2024-12-09
Posts: 7

Re: How to get tickets for a certain group with REST API?

cconard96 wrote:

/apirest.php/Group/2/Ticket is not going to work because Ticket isn't a child type. The current API sees the "Ticket" part at the end and ignores everything before it.

You should be using "/apirest.php/search/Ticket" (/apirest.php#content-search-items has the documentation for it).
Search option ID 71 is the requester group option.

Thank you very much! I'll read about it in documentation smile

Offline

#5 2024-12-09 10:54:54

little_devil
Member
Registered: 2024-12-09
Posts: 7

Re: How to get tickets for a certain group with REST API?

cconard96 wrote:

As a side-note, a new API will be coming in GLPI 11 which is more user friendly and not as low-level so confusion and unexpected behavior with paths like this shouldn't be an issue. The current API will remain as a "legacy API".

One more question, if you don't mind: wil it be possible to use "legacy API" and to send requests?

Offline

#6 2024-12-09 11:04:36

cconard96
Moderator
Registered: 2018-07-31
Posts: 3,226
Website

Re: How to get tickets for a certain group with REST API?

The legacy API is the same API that currently exists. It is just a name change to get people using the new "High-Level API" whenever possible. The current API is directly related to the GLPI code and database layout which means it is supports every type of thing in GLPI but also means it is very difficult to understand.

The "/apirest.php" path will still work. In GLPI 11 the new API will start at "version 2" and redirect calls for "version 1" to the old API.

/api.php/Computer - List computers using the latest version of the High-Level API
/api.php/v2/Computer - List computers explicitly using version 2.0
/api.php/v1/Computer - Redirects call to /apirest.php/Computer


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#7 2024-12-09 20:20:04

little_devil
Member
Registered: 2024-12-09
Posts: 7

Re: How to get tickets for a certain group with REST API?

cconard96 wrote:

The legacy API is the same API that currently exists. It is just a name change to get people using the new "High-Level API" whenever possible. The current API is directly related to the GLPI code and database layout which means it is supports every type of thing in GLPI but also means it is very difficult to understand.

The "/apirest.php" path will still work. In GLPI 11 the new API will start at "version 2" and redirect calls for "version 1" to the old API.

/api.php/Computer - List computers using the latest version of the High-Level API
/api.php/v2/Computer - List computers explicitly using version 2.0
/api.php/v1/Computer - Redirects call to /apirest.php/Computer

Okiiee, Thanks!

Offline

Board footer

Powered by FluxBB