获取设备

命名空间:microsoft.graph

获取 device 对象的属性和关系。

权限

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) Device.Read.All、Directory.Read.All、Directory.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。
应用程序 Device.Read.All、Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All

HTTP 请求

请求 {id} 中是设备 ID 属性的 值,而不是 deviceId 属性的值。

GET /devices/{id}

可选的查询参数

此方法支持 $select OData 查询参数 ,以帮助自定义响应。

请求标头

名称 类型 说明
Authorization string Bearer {token}。必需。

请求正文

请勿提供此方法的请求正文。

响应

如果成功,此方法在响应正文中返回 200 OK 响应代码和 device 对象。

示例

示例 1:获取设备

请求

下面展示了示例请求。

GET https://graph.microsoft.com/v1.0/devices/000005c3-b7a6-4c61-89fc-80bf5ccfc366

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

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

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#devices/$entity",
  "@odata.id": "https://graph.microsoft.com/v2/72f988bf-86f1-41af-91ab-2d7cd011db47/directoryObjects/000005c3-b7a6-4c61-89fc-80bf5ccfc366/Microsoft.DirectoryServices.Device",
  "accountEnabled":false,
  "deviceId":"6fa60d52-01e7-4b18-8055-4759461fc16b",
  "displayName":"DESKTOP-858MANH",
  "id": "000005c3-b7a6-4c61-89fc-80bf5ccfc366",
  "operatingSystem":"Windows",
  "operatingSystemVersion":"10.0.19043.1165"
}

示例 2:获取设备并仅返回其 ID 和 extensionAttributes 属性

请求

以下请求检索设备的 IDextensionAttributes 属性。

GET https://graph.microsoft.com/beta/devices/6a59ea83-02bd-468f-a40b-f2c3d1821983?$select=id,extensionAttributes

响应

下面展示了示例响应。

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

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#devices(id,extensionAttributes)/$entity",
    "id": "6a59ea83-02bd-468f-a40b-f2c3d1821983",
    "extensionAttributes": {
        "extensionAttribute1": "BYOD-Device",
        "extensionAttribute2": null,
        "extensionAttribute3": null,
        "extensionAttribute4": null,
        "extensionAttribute5": null,
        "extensionAttribute6": null,
        "extensionAttribute7": null,
        "extensionAttribute8": null,
        "extensionAttribute9": null,
        "extensionAttribute10": null,
        "extensionAttribute11": null,
        "extensionAttribute12": null,
        "extensionAttribute13": null,
        "extensionAttribute14": null,
        "extensionAttribute15": null
    }
}