更新 directorySetting
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新特定目录设置对象的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
对于除“同意策略设置”对象以外的所有设置
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Directory.ReadWrite.All
对于“同意策略设置”对象
更新“同意策略设置” directorySetting 对象需要以下权限。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Policy.ReadWrite.Authorization
委派(个人 Microsoft 帐户)
不支持。
应用程序
Policy.ReadWrite.Authorization
HTTP 请求
更新租户范围的设置。
PATCH /settings/{directorySettingId}
更新特定于组的设置。
PATCH /groups/{groupId}/settings/{directorySettingId}
名称
说明
Authorization
Bearer {token}。必需。
请求正文
在请求正文中,提供应更新的相关字段的值。
响应
如果成功,此方法返回 204 OK 响应代码。
示例
请求
下面是一个请求示例。
PATCH https://graph.microsoft.com/beta/settings/3c105fc3-2254-4861-9e2d-d59e2126f3ef
Content-type: application/json
{
"values": [
{
"name": "CustomBlockedWordsList",
"value": "Contoso"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var directorySetting = new DirectorySetting
{
Values = new List<SettingValue>()
{
new SettingValue
{
Name = "CustomBlockedWordsList",
Value = "Contoso"
}
}
};
await graphClient.Settings["{directorySetting-id}"]
.Request()
.UpdateAsync(directorySetting);
const options = {
authProvider,
};
const client = Client.init(options);
const directorySetting = {
values: [
{
name: 'CustomBlockedWordsList',
value: 'Contoso'
}
]
};
await client.api('/settings/3c105fc3-2254-4861-9e2d-d59e2126f3ef')
.version('beta')
.update(directorySetting);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/settings/3c105fc3-2254-4861-9e2d-d59e2126f3ef"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphDirectorySetting *directorySetting = [[MSGraphDirectorySetting alloc] init];
NSMutableArray *valuesList = [[NSMutableArray alloc] init];
MSGraphSettingValue *values = [[MSGraphSettingValue alloc] init];
[values setName:@"CustomBlockedWordsList"];
[values setValue:@"Contoso"];
[valuesList addObject: values];
[directorySetting setValues:valuesList];
NSError *error;
NSData *directorySettingData = [directorySetting getSerializedDataWithError:&error];
[urlRequest setHTTPBody:directorySettingData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DirectorySetting directorySetting = new DirectorySetting();
LinkedList<SettingValue> valuesList = new LinkedList<SettingValue>();
SettingValue values = new SettingValue();
values.name = "CustomBlockedWordsList";
values.value = "Contoso";
valuesList.add(values);
directorySetting.values = valuesList;
graphClient.settings("3c105fc3-2254-4861-9e2d-d59e2126f3ef")
.buildRequest()
.patch(directorySetting);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewDirectorySetting()
requestBody.SetValues( []SettingValue {
msgraphsdk.NewSettingValue(),
SetAdditionalData(map[string]interface{}{
"name": "CustomBlockedWordsList",
"value": "Contoso",
}
}
directorySettingId := "directorySetting-id"
graphClient.SettingsById(&directorySettingId).Patch(requestBody)
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
Values = @(
@{
Name = "CustomBlockedWordsList"
Value = "Contoso"
}
)
}
Update-MgDirectorySetting -DirectorySettingId $directorySettingId -BodyParameter $params
响应
HTTP/1.1 204 OK