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 2023-09-27 10:15:15

pubuduhashan
Member
Registered: 2023-09-27
Posts: 3

REST API listSearchOptions does not return the "Id" field.

listSearchOptions does not return the field called Id. I need to get the item Id when using listSearchOptions forcedisplay option.
Can someone please assist?

Offline

#2 2023-09-27 14:49:55

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: REST API listSearchOptions does not return the "Id" field.

Iwould say  "id"   is allways index 2   forcedisplay[x]=2


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

#3 2023-09-27 21:09:41

pubuduhashan
Member
Registered: 2023-09-27
Posts: 3

Re: REST API listSearchOptions does not return the "Id" field.

Hi LaDenrée,

I tried as you suggested. But it doesn't return id field in the search/computer method. In the listSearchOptions also index 2 is missing with some other indexes (like 3,7).

Offline

#4 2023-09-28 08:32:05

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: REST API listSearchOptions does not return the "Id" field.

myserver/glpi/apirest.php/listSearchOptions/Computer/   
returns

{"common":{"name":"Caractéristiques"},
"1":{"name":"Nom","table":"glpi_computers","field":"name","datatype":"itemlink","nosearch":false,"nodisplay":false,"available_searchtypes":["contains","notcontains","equals","notequals"],"uid":"Computer.name"},
"2":{"name":"ID","table":"glpi_computers","field":"id","datatype":"number","nosearch":false,"nodisplay":false,"available_searchtypes":["contains","notcontains"],"uid":"Computer.id"},
"3":{"name":"Lieu","table":"glpi_locations","field":"completename","datatype":"dropdown","nosearch":false,"nodisplay":false,"available_searchtypes":["contains","notcontains","equals","notequals","under","notunder"],"uid":"Computer.Location.completename"},"101":{"name":"Adresse","table":"glpi_locations","field":"address","datatype":"string","nosearch":false,"nodisplay":false,"available_searchtypes":["contains","notcontains"],"uid":"Computer.Location.address"},"102":{"name":"Code postal","table":"glpi_locations","field":"postcode","datatype":"string","nosearch":false,"nodisplay":false,"available_searchtypes":["contains","notcontains"],"uid":"Computer.Location.postcode"},  [...] 

index 2 is in the response


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

#5 2023-09-28 17:09:42

pubuduhashan
Member
Registered: 2023-09-27
Posts: 3

Re: REST API listSearchOptions does not return the "Id" field.

Yes, I have tried this in the local dev setup. It works as you mentioned. However, the production server is not returning these fields. The ID field is missing in the response. Maybe because of a GLPI configuration error?

Offline

#6 2023-09-29 15:19:24

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: REST API listSearchOptions does not return the "Id" field.

I cannot recreate the issue. Is your dev setup a different GLPI or PHP version? Also, the order of the options returned is not guaranteed to be in numeric order based on the ID.


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

Board footer

Powered by FluxBB