18 Feb 2022
	
		
		04:43 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		21 Aug 2024
	
		
		09:28 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		 Michal_Gebacki
		
			Michal_Gebacki
		
		
		
		
		
		
		
		
	
			
		
I am trying to pull in ALL my hostgroup ID's from the DT API.
It used to work using 
Solved! Go to Solution.
03 Mar 2022 09:13 AM
You can try using the Monitored Entities API, using the entity type HOST_GROUP should give you what you are looking for:
/api/v2/entities?entitySelector=type%28%22host_group%22%29
20 Jun 2023 02:42 PM
Hi Axel,
There appears to be a bug in this API, when issuing a nextPageKey parameter is throws an exception
{
  "error": {
    "code": 400,
    "message": "Constraints violated.",
    "constraintViolations": [
      {
        "path": "entitySelector",
        "message": "must not be used in combination with nextPageKey query parameter.",
        "parameterLocation": "QUERY",
        "location": null
      },
      {
        "path": "pageSize",
        "message": "must not be used in combination with nextPageKey query parameter.",
        "parameterLocation": "QUERY",
        "location": null
      }
    ]
  }
}18 Aug 2023 06:58 PM
You must remove ALL parameters before using the nextPageKey or you will get the errors you show here.
05 Feb 2024 09:43 PM
This is very useful information and I was able to get the list of host groups using the API. The only question I have is how do I associate these host_groups to the hosts themselves? I don't see a shared host Id/host group id, or at least know how to properly format the URL to pull both information together to allow me to view what host groups are associated to a given host.
05 Feb 2024 09:59 PM
I dont think the Host group monitored API information gives you that, unfortunately you would need a second call for hosts, and that info is part of the available properties:
/api/v2/entities?entitySelector=type("host")&fields=properties.hostgroupname
