Create extensionProperty (directory extension)
Article
10/14/2022
2 minutes to read
6 contributors
Feedback
In this article
Namespace: microsoft.graph
Create a new directory extension definition, represented by an extensionProperty object.
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)
Application.ReadWrite.All
Delegated (personal Microsoft account)
Application.ReadWrite.All
Application
Application.ReadWrite.OwnedBy, Application.ReadWrite.All
HTTP request
POST /applications/{application ObjectId}/extensionProperties
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
Request body
In the request body, provide an extensionProperty object with the following properties.
Property
Type
Description
dataType
String
Specifies the data type of the value the extension property can hold. Following values are supported. Not nullable. Binary
- 256 bytes maximumBoolean
DateTime
- Must be specified in ISO 8601 format. Will be stored in UTC.Integer
- 32-bit value.LargeInteger
- 64-bit value.String
- 256 characters maximum
name
String
Name of the extension property. Not nullable.
targetObjects
String collection
The Microsoft Graph resources that can use the extension property. All values must be in PascalCase. The following values are supported. Not nullable. User
Group
AdministrativeUnit
Application
Device
Organization
Response
If successful, this method returns a 201 Created
response code and a new extensionProperty object in the response body.
Examples
Request
The following is an example of the request.
POST https://graph.microsoft.com/v1.0/applications/fd918e4b-c821-4efb-b50a-5eddd23afc6f/extensionProperties
Content-type: application/json
{
"name": "jobGroup",
"dataType": "String",
"targetObjects": [
"User"
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var extensionProperty = new ExtensionProperty
{
Name = "jobGroup",
DataType = "String",
TargetObjects = new List<String>()
{
"User"
}
};
await graphClient.Applications["{application-id}"].ExtensionProperties
.Request()
.AddAsync(extensionProperty);
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 extensionProperty = {
name: 'jobGroup',
dataType: 'String',
targetObjects: [
'User'
]
};
await client.api('/applications/fd918e4b-c821-4efb-b50a-5eddd23afc6f/extensionProperties')
.post(extensionProperty);
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();
ExtensionProperty extensionProperty = new ExtensionProperty();
extensionProperty.name = "jobGroup";
extensionProperty.dataType = "String";
LinkedList<String> targetObjectsList = new LinkedList<String>();
targetObjectsList.add("User");
extensionProperty.targetObjects = targetObjectsList;
graphClient.applications("fd918e4b-c821-4efb-b50a-5eddd23afc6f").extensionProperties()
.buildRequest()
.post(extensionProperty);
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.NewExtensionProperty()
name := "jobGroup"
requestBody.SetName(&name)
dataType := "String"
requestBody.SetDataType(&dataType)
targetObjects := []string {
"User",
}
requestBody.SetTargetObjects(targetObjects)
result, err := graphClient.ApplicationsById("application-id").ExtensionProperties().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.Applications
$params = @{
Name = "jobGroup"
DataType = "String"
TargetObjects = @(
"User"
)
}
New-MgApplicationExtensionProperty -ApplicationId $applicationId -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 ExtensionProperty();
$requestBody->setName('jobGroup');
$requestBody->setDataType('String');
$requestBody->setTargetObjects(['User', ]);
$requestResult = $graphServiceClient->applicationsById('application-id')->extensionProperties()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
If successful, this method returns 201 Created
response code and extensionProperty object in the response body.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#applications('fd918e4b-c821-4efb-b50a-5eddd23afc6f')/extensionProperties/$entity",
"id": "da38c7b1-133e-4a79-abcd-e2fd586ce621",
"deletedDateTime": null,
"appDisplayName": "b2c-extensions-app. Do not modify. Used by AADB2C for storing user data.",
"dataType": "String",
"isSyncedFromOnPremises": false,
"name": "extension_25883231668a43a780b25685c3f874bc_jobGroup",
"targetObjects": [
"User"
]
}