Get a list of devices for the specified batch and customer

Applies To

  • Partner Center
  • Partner Center for Microsoft Cloud Germany

How to retrieve a collection of devices in the specified device batch for the specified customer. Each device resource contains details about the device.

Prerequisites

  • Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.
  • The customer identifier.
  • The device batch identifier.

To retrieve a collection of the devices in a specified device batch for the specified customer, first call the IAggregatePartner.Customers.ById method with the customer ID to retrieve an interface to operations on the specified customer. Then, call the DeviceBatches.ById method to get an interface to device batch collection operations for the specified batch. Next, retrieve the Devices property to get an interface to device collection operations for the batch. Finally, call the Get or GetAsync method to retrieve the collection of devices.

IAggregatePartner partnerOperations;
string selectedCustomerId;
string selectedDeviceBatchId;

var devices = 
    partnerOperations.Customers.ById(selectedCustomerId).DeviceBatches.ById(selectedDeviceBatchId).Devices.Get();

Sample: Console test app. Project: Partner Center SDK Samples Class: GetDevices.cs

Request

Request syntax

Method Request URI
GET {baseURL}/v1/customers/{customer-id}/deviceBatches/{devicebatch-id}/devices HTTP/1.1

URI parameter

Use the following path parameters when creating the request.

Name Type Required Description
customer-id string Yes A GUID-formatted string that identifies the customer.
devicebatch-id string Yes A string identifier that identifies the device batch.

Request headers

Request body

None

Request example

GET https://api.partnercenter.microsoft.com/v1/customers/47021739-3426-40bf-9601-61b4b6d7c793/deviceBatches/testbatch/devices HTTP/1.1
Authorization: Bearer <token> 
Accept: application/json
MS-RequestId: e88d014d-ab70-41de-90a0-f7fd1797267d
MS-CorrelationId: de894e18-f027-4ac0-8b5a-34f0c222af0c
X-Locale: en-US
Host: api.partnercenter.microsoft.com

Response

If successful, the response body contains a paged collection of Device resources. The collection contains 100 devices in a page. To retrieve the next page of 100 devices, the continuationToken in the response body must be included in the subsequent request as an MS-ContinuationToken header.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center REST error codes.

Response example

HTTP/1.1 200 OK
Content-Length: 1742
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 4a5002a2-0c1b-4e57-b491-dbcf19c0e7b8
MS-RequestId: 7b3e2e00-b330-4480-9d84-59ace713427f
MS-CV: YrLe3w6BbUSMt1fi.0
MS-ServerId: 030020344
Date: Tue, 25 Jul 2017 17:52:41 GMT

{
    "totalCount": 2,
    "items":
    [{
            "id": "7c141ea9-2816-4e15-a819-53f6856499ff",
            "serialNumber": "2R9-ZNP67",
            "productKey": "00329-00000-0003-AA6069",
            "modelName": "Precision WorkStation T7500”,
            "oemManufacturerName":"Dell Inc.",
            "policies":[{
                    "key": "o_o_b_e",
                    "value": null
                }
            ],
            "uploadedDate":"2017-08-09T14:43:26.0092288-07:00",
            " attributes”: {
                "objectType": "Device"
            }
        }, {
            "id": "e528a62f-5031-49f4-bea7-5fafe47388fd",
            "serialNumber": "1234567890",
            "productKey": "12345-67890-09876-54321-13579",
            "modelName": "HP Z420 Workstation",
            "oemManufacturerName": "Hewlett-Packard",
            "policies": [{
                    "key": "o_o_b_e",
                    "value": null
                }
            ],
            "uploadedDate": "2017-08-09T14:35:51.3126144-07:00",
            "attributes": {
                "objectType": "Device"
            }
        }
    ],
    "attributes": {
        "objectType": "Collection"
    }
}