You are not logged in.
Hello everyone,
I'm currently working with an API to retrieve members of a group, but I've hit a snag. My requests only return users who are not marked as deleted (is_deleted=0). Despite exploring the available search fields, I haven't found any direct reference or option to include both active and deleted users (is_deleted=0 and is_deleted=1) in a single query.
To work around this limitation, I've resorted to making two separate requests: one with ?is_deleted=1 to fetch deleted users and another with ?is_deleted=0 for active users. However, managing two distinct queries like this isn't ideal.
I'm wondering if there's a way to combine these conditions into a single request to streamline the process. Additionally, I'm looking for guidance on obtaining a comprehensive list of field IDs available for search criteria within the API. Having a detailed list or documentation reference would greatly help refine my queries and ensure I can access all necessary data efficiently.
When I execute the API request:
apirest.php/search/User?criteria[0][field]=24&criteria[0][searchtype]=equals&criteria[0][value]=0
I successfully retrieve all users who are not marked as deleted. However, when I perform this query:
apirest.php/search/User?criteria[0][field]=24&criteria[0][searchtype]=equals&criteria[0][value]=1
I receive zero users in the response, despite having created a user and then moved them to the trash.
Could someone kindly advise why users marked as deleted (moved to trash) aren't being included in the results when querying with the value set to 1? Any insights or suggestions on how to correctly retrieve users in the trash using the GLPI API would be greatly appreciated.
Thank you for your assistance!
Last edited by Raiq (2024-03-04 17:48:17)
Offline
- I'm wondering if there's a way to combine these conditions into a single request to streamline the process.
I don't know of any way to do that. Just like the search results on the web interface you can only toggle between regular and deleted views, not see both at once. The new API coming with the next main version of GLPI (11.0) will not have that limitation.
- I'm looking for guidance on obtaining a comprehensive list of field IDs available for search criteria within the API.
The internal IDs assigned for search options/fields can be retrieved with:
apirest.php/listSearchOptions/:itemtype
This is also not going to be a concern in the new API as it isn't based on the internal search code; it uses regular property names and a RSQL syntax.
Sample response (irrelevant fields removed):
{
"id": 60,
"name": "CConardMBA",
"entity": {
"id": 0,
"name": "Root Entity",
"completename": "Root Entity"
},
}
Sample filter with the new API:
entity.name=like=Root*
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