POST https://graph.microsoft.com/v1.0/devices/{id}/registeredUsers/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Models.ReferenceCreate
{
OdataId = "https://graph.microsoft.com/v1.0/directoryObjects/{id}",
};
await graphClient.Devices["{device-id}"].RegisteredUsers.Ref.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc devices registered-users ref post --device-id {device-id} --body '{\
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"\
}\
'
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ReferenceCreate();
$requestBody->setOdataId('https://graph.microsoft.com/v1.0/directoryObjects/{id}');
$graphServiceClient->devices()->byDeviceId('device-id')->registeredUsers()->ref()->post($requestBody)->wait();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = ReferenceCreate(
odata_id = "https://graph.microsoft.com/v1.0/directoryObjects/{id}",
)
await graph_client.devices.by_device_id('device-id').registered_users.ref.post(body = request_body)