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-06-13 10:38:27

GoldfischMann
Member
Registered: 2022-06-13
Posts: 7

Get networks via API

Hello everyone

I have to query some Computers via the REST-API in order to get their networkname and ip-adress.
Unfortunately I haven't been able to find a way to reliably connect the networkname to the ip-adress.

Following are my search criteria:

 
"criteria":
 [
    {
       "field":      76692,   ### a custom field I need to query by
       "searchtype": 'equals',
       "value":      '1'
    }
 ],
"forcedisplay":
 [
   { "126" },
   { "127" }
 ]


Full query:
http://myGLIPIinstance.com/apirest.php/search/Computer?criteria%5B0%5D%5Bfield%5D=76692&criteria%5B0%5D%5Bsearchtype%5D=equals&criteria%5B0%5D%5Bvalue%5D=1&forcedisplay%5B0%5D=126&forcedisplay%5B1%5D=127

This results in following output:

{
	"totalcount": 1,
	"count": 1,
	"sort": [
		"1"
	],
	"order": [
		"ASC"
	],
	"data": [
		{
			"1": "some-server",
			"80": "Organisationen > someOrg",
			"126": [
				"127.0.0.1",
				"::1",
				"192.xx.xx.xx",
				"fe80::xx:xx:xx:xx",
				"172.xx.xx.xx",
				"fe80::1x:xx:xx:xx",
				"fe80::2x:xx:xx:xx",
				"192.xx.xx.xx",
				"155.xx.xx.xx"

			],
			"127": [
				null,
				"monitoring",
				"someRandomName",
				null,
				"anotherName"
			],
			"76692": 1
		}
		
	],
	"content-range": "0-1/1"
}

So far so good.
But now I cannot reliably determine which ip-adresses belong to which network name, especially after adding more ip-adresses.
E.g. the 155.xx ip-adress belongs to the "monitoring" name.


So my question being:
Is there some way to get the networkports directly so that name and ip-adresses are inside of one object or is there any other way to get the link between these two?


Thank you very much in advance.

Greetings

Last edited by GoldfischMann (2022-06-13 10:40:08)

Offline

Board footer

Powered by FluxBB