Create a group setting
10/7/2020
2 minutes to read
In this article
Namespace: microsoft.graph
Use this API to create a new setting, based on the templates available in groupSettingTemplates . These settings can be at the tenant-level or at the group level. The creation request must provide settingValues for all the settings defined in the template. For group-specific settings, only the setting governing whether members of a group can invite guest users can be set. This will govern this behavior once the ability to add guest users to a group is generally available. For beta endpoints, use directorySettingTemplates .
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.ReadWrite.All, Directory.AccessAsUser.All
Delegated (personal Microsoft account)
Not supported.
Application
Directory.ReadWrite.All
HTTP request
POST /groupSettings
POST /groups/{id}/settings
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json
Request body
In the request body, supply a JSON representation of groupSetting object. However, the display name for the setting will be set based on the referenced settings template name.
Response
If successful, this method returns 201 Created
response code and groupSetting object in the response body.
Example
Request
POST https://graph.microsoft.com/v1.0/groupSettings
Content-type: application/json
Content-length: 215
{
"displayName": "displayName-value",
"templateId": "templateId-value",
"values": [
{
"name": "name-value",
"value": "value-value"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groupSetting = new GroupSetting
{
DisplayName = "displayName-value",
TemplateId = "templateId-value",
Values = new List<SettingValue>()
{
new SettingValue
{
Name = "name-value",
Value = "value-value"
}
}
};
await graphClient.GroupSettings
.Request()
.AddAsync(groupSetting);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const groupSetting = {
displayName: "displayName-value",
templateId: "templateId-value",
values: [
{
name: "name-value",
value: "value-value"
}
]
};
let res = await client.api('/groupSettings')
.post(groupSetting);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groupSettings"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphGroupSetting *groupSetting = [[MSGraphGroupSetting alloc] init];
[groupSetting setDisplayName:@"displayName-value"];
[groupSetting setTemplateId:@"templateId-value"];
NSMutableArray *valuesList = [[NSMutableArray alloc] init];
MSGraphSettingValue *values = [[MSGraphSettingValue alloc] init];
[values setName:@"name-value"];
[values setValue:@"value-value"];
[valuesList addObject: values];
[groupSetting setValues:valuesList];
NSError *error;
NSData *groupSettingData = [groupSetting getSerializedDataWithError:&error];
[urlRequest setHTTPBody:groupSettingData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
GroupSetting groupSetting = new GroupSetting();
groupSetting.displayName = "displayName-value";
groupSetting.templateId = "templateId-value";
LinkedList<SettingValue> valuesList = new LinkedList<SettingValue>();
SettingValue values = new SettingValue();
values.name = "name-value";
values.value = "value-value";
valuesList.add(values);
groupSetting.values = valuesList;
graphClient.groupSettings()
.buildRequest()
.post(groupSetting);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
In the request body, supply a JSON representation of groupSetting object.
Response
Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-type: application/json
Content-length: 238
{
"displayName": "displayName-value",
"templateId": "templateId-value",
"values": [
{
"name": "name-value",
"value": "value-value"
}
],
"id": "id-value"
}