One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Directory.Read.All
Delegated (personal Microsoft account)
Not supported.
Application
Directory.Read.All
When an application queries a relationship that returns a directoryObject type collection, if it does not have permission to read a certain derived type (like device), members of that type are returned but with limited information. With this behavior, applications can request the least privileged permissions they need, rather than rely on the set of Directory.* permissions. For details, see Limited information returned for inaccessible member objects.
HTTP request
POST /directoryObjects/getByIds
Request headers
Name
Description
Authorization
Bearer {token}. Required.
Content-type
application/json. Required.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
ids
String collection
A collection of IDs for which to return objects. The IDs are GUIDs, represented as strings. You can specify up to 1000 IDs.
types
String collection
A collection of resource types that specifies the set of resource collections to search. If not specified, the default is directoryObject, which contains all of the resource types defined in the directory. Any object that derives from directoryObject may be specified in the collection; for example: user, group, and device objects.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.DirectoryObjects.GetByIds.GetByIdsPostRequestBody
{
Ids = new List<string>
{
"84b80893-8749-40a3-97b7-68513b600544",
"5d6059b6-368d-45f8-91e1-8e07d485f1d0",
"0b944de3-e0fc-4774-a49a-b135213725ef",
"b75a5ab2-fe55-4463-bd31-d21ad555c6e0",
},
Types = new List<string>
{
"user",
"group",
"device",
},
};
var result = await graphClient.DirectoryObjects.GetByIds.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc directory-objects get-by-ids post --body '{\
"ids": [\
"84b80893-8749-40a3-97b7-68513b600544",\
"5d6059b6-368d-45f8-91e1-8e07d485f1d0",\
"0b944de3-e0fc-4774-a49a-b135213725ef",\
"b75a5ab2-fe55-4463-bd31-d21ad555c6e0"\
],\
"types": [\
"user",\
"group",\
"device"\
]\
}\
'
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GetByIdsPostRequestBody();
$requestBody->setIds(['84b80893-8749-40a3-97b7-68513b600544', '5d6059b6-368d-45f8-91e1-8e07d485f1d0', '0b944de3-e0fc-4774-a49a-b135213725ef', 'b75a5ab2-fe55-4463-bd31-d21ad555c6e0', ]);
$requestBody->setTypes(['user', 'group', 'device', ]);
$result = $graphServiceClient->directoryObjects()->getByIds()->post($requestBody)->wait();