Get directory objects from a list of ids

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.

Return the directory objects specified in a list of IDs.

Some common uses for this function are to:

  • Resolve IDs returned by functions (that return collections of IDs) such as getMemberObjects or getMemberGroups to their backing directory objects.
  • Resolve IDs persisted in an external store by the application to their backing directory objects.

Permissions

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 behaviour 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 Type Description
Authorization string Bearer {token}. Required.
Content-type string 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, device, and so on. To search for references to a Cloud Solution Provider partner organization specify directoryObjectPartnerReference. If not specified, the default is directoryObject, which contains all of the resource types defined in the directory, except for references to a Cloud Solution Provider partner organization. The values are not case-sensitive.

Response

If successful, this method returns a 200 OK response code and a string collection object in the response body.

Example

Request

POST https://graph.microsoft.com/beta/directoryObjects/getByIds
Content-type: application/json

{
    "ids":["84b80893-8749-40a3-97b7-68513b600544","5d6059b6-368d-45f8-91e1-8e07d485f1d0"],
    "types":["user"]
}

Response

Note: The response object shown here might be shortened for readability. All the properties will be returned from an actual call.

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#directoryObjects",
    "value": [
      {
        "@odata.type": "#microsoft.graph.user",
        "id": "84b80893-8749-40a3-97b7-68513b600544",
        "accountEnabled": true,
        "displayName": "Trevor Jones"
      },
      {
        "@odata.type": "#microsoft.graph.user",
        "id": "84b80893-8749-40a3-97b7-68513b600544",
        "accountEnabled": true,
        "displayName": "Billy Smith"
      }
    ]
}