azuremicrosoft-graph-apiintunemicrosoft-graph-intune

I am trying to get all the applications installed on all the devices using microsoft graph API


I am trying to get all the applications installed on all the devices ios,ipad,iphone,android and windows devices using microsoft graph API.

my approach was first to get all the devices using https://graph.microsoft.com/v1.0/deviceManagement/manageddevices and then passing each device id to https://graph.microsoft.com/v1.0/deviceManagement/manageddevices('device_id')?$expand=detectedApps

but there are huge number of devices so the number of API calls i have to make is too many.

Is there any alternate way to do it .

Note:i tried https://graph.microsoft.com/v1.0/deviceManagement/manageddevices?$expand=detectedApps here but this seems to be not working.

Thanks


Solution

  • managedDevice resource type doesn't have any relationship to detectedApp but detectedApp resource type has a relationship to managedDevice.

    Make a first call to get all devices

    GET https://graph.microsoft.com/v1.0/deviceManagement/manageddevices
    

    You can reduce the size of the response by selecting only some properties you need

    GET https://graph.microsoft.com/v1.0/deviceManagement/manageddevices?$select=id
    

    Then the second call to get detected apps and expand managedDevices

    GET https://graph.microsoft.com/v1.0/deviceManagement/detectedApps?$expand=managedDevices
    GET https://graph.microsoft.com/v1.0/deviceManagement/detectedApps?$expand=managedDevices($select=id)
    

    Group detected apps from the second call by managed device id and compare them with a list of all devices from the first call to find out which devices have apps.

    Resources:

    List managed devices

    List detected apps

    detectedApp resource