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 2022-10-05 19:19:30

aziz
Member
Registered: 2021-03-30
Posts: 109

printers connected to computer

Hello everybody,

How can I get printers connected to a specific computer (computer ID) using API request .
TY.

Offline

#2 2022-10-05 22:32:55

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: printers connected to computer

I tried using this URL : http://myglpiserver/glpi/search/apirest.php/printer/?is_deleted=0&as_map=0&criteria[0][link]=AND&criteria[0][itemtype]=Computer&criteria[0][meta]=1&criteria[0][field]=2&criteria[0][searchtype]=contains&criteria[0][value]=^Computer_ID$

But I keep getting the same response :
{
    "totalcount": 0,
    "count": 0,
    "sort": "1",
    "order": "ASC",
    "content-range": "0--1/0"
}
even when there is a printer conencted to taht computer

Offline

#3 2022-10-06 01:20:28

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

Re: printers connected to computer

That seems to work properly for me. The only thing is the API endpoint URL is wrong but I think that is just a typo here.
The correct URL should be:
"/apirest.php/search/Printer/?is_deleted=0&as_map=0&criteria[0][link]=AND&criteria[0][itemtype]=Computer&criteria[0][meta]=1&criteria[0][field]=2&criteria[0][searchtype]=contains&criteria[0][value]=^Computer_ID$"

Note that the "search" part is after "apirest.php". Also, even though it works both ways for me, the current API is case-sensitive in some cases for item types, so "printer" should be "Printer".


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 2022-10-06 11:45:36

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: printers connected to computer

That's weird, and really confusing me, I think I'm doing everything right tho :
this is the printer connected with computer with id 3 :
https://ibb.co/H7hgRxg
but when I use this URL  : myglpiserver/glpi/apirest.php/search/Printer/?is_deleted=0&as_map=0&criteria[0][link]=AND&criteria[0][itemtype]=Computer&criteria[0][meta]=1&criteria[0][field]=2&criteria[0][searchtype]=contains&criteria[0][value]=^3$
I get this response :
https://ibb.co/LP2ZS0M

when doing the same thing with software it works fine.
this is the software installed in computer with id 3 :
https://ibb.co/cLmzrhq

and when I use the same URL only changing printer with software : myglpiserver/glpi/apirest.php/search/Printer/?is_deleted=0&as_map=0&criteria[0][link]=AND&criteria[0][itemtype]=Computer&criteria[0][meta]=1&criteria[0][field]=2&criteria[0][searchtype]=contains&criteria[0][value]=^3$
I get this response :
https://ibb.co/8N1R84M
....

Offline

#5 2022-10-06 12:26:17

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

Re: printers connected to computer

Does the user you are using to connect to the API have multiple profiles?
If so, can you check the correct one is active with "apirest.php/getActiveProfile/"?

Also, which version of GLPI are you using?


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

#6 2022-10-06 13:18:35

aziz
Member
Registered: 2021-03-30
Posts: 109

Re: printers connected to computer

No the user  i'm using  has a super admin profile and does not have multiple profiles .
the glpi version I'm using is 9.5.4

Offline

#7 2022-10-06 22:49:03

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

Re: printers connected to computer

I was testing with 10.0.3.
The only suggestion I have currently is to try updating to at least the latest bug fix version of 9.5.X which is 9.5.9 currently and see if this is a bug that was already fixed.


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