Create registeredOwner
Article
12/08/2022
2 minutes to read
12 contributors
Feedback
In this article
Namespace: microsoft.graph
Add a user as a registered owner of the device.
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.AccessAsUser.All
Delegated (personal Microsoft account)
Not supported.
Application
Not supported.
HTTP request
You can address the device using either its id or deviceId .
POST /devices/{id}/registeredOwners/$ref
POST /devices(deviceId='{deviceId}')/registeredOwners/$ref
Name
Description
Authorization
Bearer {token}. Required.
Request body
In the request body, supply a JSON representation of directoryObject object.
Response
If successful, this method returns a 204 No Content
response code.
Example
Request
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/devices/{id}/registeredOwners/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var directoryObject = new DirectoryObject
{
Id = "{id}"
};
await graphClient.Devices["{device-id}"].RegisteredOwners.References
.Request()
.AddAsync(directoryObject);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const directoryObject = {
'@odata.id': 'https://graph.microsoft.com/v1.0/directoryObjects/{id}'
};
await client.api('/devices/{id}/registeredOwners/$ref')
.post(directoryObject);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DirectoryObject directoryObject = new DirectoryObject();
directoryObject.id = "{id}";
graphClient.devices("{id}").registeredOwners().references()
.buildRequest()
.post(directoryObject);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := graphmodels.NewReferenceCreate()
"@odata.id" := "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
requestBody.Set"@odata.id"(&"@odata.id")
graphClient.DevicesById("device-id").RegisteredOwners().$ref().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
New-MgDeviceRegisteredOwnerByRef -DeviceId $deviceId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new ReferenceCreate();
$requestBody->set@odataid('https://graph.microsoft.com/v1.0/directoryObjects/{id}');
$graphServiceClient->devicesById('device-id')->registeredOwners()->ref()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
In the request body, supply a JSON representation of directoryObject object.
Response
Here is an example of the response. Note: The response object shown here might be shortened for readability.
HTTP/1.1 204 No content