更新 userInsightsSettings
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新用户 itemInsights 和 会议时间见解 的隐私设置。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
User.ReadWrite
委派(个人 Microsoft 帐户)
不支持。
应用程序
不支持。
HTTP 请求
PATCH /me/settings/itemInsights
PATCH /users/{userId}/settings/itemInsights
注意: 具有 或 的请求仅可供用户或具有 userId userPrincipalName User.ReadWrite.All 权限的用户访问。 若要了解详细信息,请参阅权限 。
标头
值
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,提供应更新的相关字段的值。请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。为了获得最佳性能,不应包括尚未更改的现有值。
属性
类型
说明
isEnabled
Boolean
true 如果用户的 itemInsights 和会议时间见解已启用; false 如果禁用了 用户的 itemInsights 和会议小时数见解。 默认值为“true”。 可选。
响应
如果成功,此方法在响应正文中返回 响应代码和 200 OK userInsightsSettings 对象。
示例
请求
下面是有关用户如何更新"isEnabled" 隐私设置以禁用其项目见解和会议时间见解的示例请求。
PATCH https://graph.microsoft.com/beta/users/{userId}/settings/itemInsights
Content-type: application/json
{
"isEnabled": "false"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var userInsightsSettings = new UserInsightsSettings
{
IsEnabled = false
};
await graphClient.Users["{user-id}"].Settings.ItemInsights
.Request()
.UpdateAsync(userInsightsSettings);
const options = {
authProvider,
};
const client = Client.init(options);
const userInsightsSettings = {
isEnabled: 'false'
};
await client.api('/users/{userId}/settings/itemInsights')
.version('beta')
.update(userInsightsSettings);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/users/{userId}/settings/itemInsights"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphUserInsightsSettings *userInsightsSettings = [[MSGraphUserInsightsSettings alloc] init];
[userInsightsSettings setIsEnabled:@"false"];
NSError *error;
NSData *userInsightsSettingsData = [userInsightsSettings getSerializedDataWithError:&error];
[urlRequest setHTTPBody:userInsightsSettingsData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UserInsightsSettings userInsightsSettings = new UserInsightsSettings();
userInsightsSettings.isEnabled = false;
graphClient.users("{userId}").settings().itemInsights()
.buildRequest()
.patch(userInsightsSettings);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewUserInsightsSettings()
isEnabled := "false"
requestBody.SetIsEnabled(&isEnabled)
userId := "user-id"
graphClient.UsersById(&userId).Settings().ItemInsights().Patch(requestBody)
Import-Module Microsoft.Graph.Users
$params = @{
IsEnabled = "false"
}
Update-MgUserSettingItemInsight -UserId $userId -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"isEnabled": false,
}