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-04-27 17:36:58

blackxthink
Member
Registered: 2021-12-03
Posts: 5

Items in URL for API queries

Hello,

I am looking for a much more precise documentation about the apirest.
I managed to make what I needed through trial and error to find the names to put after   [...]/apirest.php/HERE/?sessiontoken

I was looking for the list or atleast how to find the name required to work with.
Please note that I am not using Curl, i am programming a tool under python using a module that requires the URL.
(which is also the same way i am testing things out with postman)

The thing is that i am looking for a way to add a network port on computers to add the actual mac address (and probably the IP)
but I cant seem to "easily" find informations about what I am asking right now.

It asks for "itemType" but it does not specify anywhere where to find all the names to easily work with them.

RxMXQd5.png

The reason we are programming a tool with python is to add all our computers manually without using any type of clients while still automating the addition process with the computer informations.

Thank you very much in advance !

Offline

#2 2022-04-27 19:57:14

blackxthink
Member
Registered: 2021-12-03
Posts: 5

Re: Items in URL for API queries

I managed to find it here:

apirest.php/Computer/:id/NetworkPort/


But i am still curious, is there a list somewhere of the types like :
Computer
NetworkPort

Offline

#3 2022-04-27 20:09:08

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

Re: Items in URL for API queries

There is no good list. This API is very low level. You can guess what the valid itemtypes are based on the PHP class names. In GLPI 9.5.X and earlier, these would be the files in the inc folder. In GLPI 10, these files were mostly moved to the src folder.
For example, computer.class.php in GLPI 9.5 refers to "Computer" itemtype. Itemtypes always have the first letter capitalized and the file extensions should not be included (.class.php, .php).


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-04-27 21:49:35

blackxthink
Member
Registered: 2021-12-03
Posts: 5

Re: Items in URL for API queries

I have tried adding a network port based from another topic on this forum and I cant figure out what's not working out:
/viewtopic.php?id=167092


OQZbW5A.png

jzUYlfW.png

Last edited by blackxthink (2022-04-27 22:00:10)

Offline

#5 2022-04-28 04:15:07

blackxthink
Member
Registered: 2021-12-03
Posts: 5

Re: Items in URL for API queries

Ok... Finally managed to fix it.

The URL in postman was HTTP but shouldve been HTTPS

Offline

Board footer

Powered by FluxBB