我尝试使用 Microsoft Graph API 提取与特定用户关联的敏感度标签列表,但遇到了困难。这是我尝试过的 API 调用:
GET https://graph.microsoft.com/v1.0/users/{id}/security/informationProtection/sensitivityLabels
不幸的是,我收到了 400 Bad Request 错误,并且消息中提到了有关意外段的内容:
{
"error": {
"code": "Request_BadRequest",
"message": "Unexpected segment DynamicPathSegment. Expected property/$value.",
...
}
}
我也在 C# 中尝试过这个:
var result = await graphClient.Users["{id}"].Security.InformationProtection.SensitivityLabels.GetAsync();
但是我遇到了这个错误:
CS1061 'UserItemRequestBuilder' does not contain a definition for 'Security'...
有人成功检索到用户的敏感度标签吗?如果是这样,你能给我指出正确的方向吗?我真的很感激任何帮助!
请注意,通过 MS Graph API 检索与用户关联的敏感度标签仅在Beta版本中可用,而不是在 v1.0 中。
我有以下与我的租户用户相关的敏感度标签列表:
现在,我注册了一个应用程序,并在管理员同意的情况下授予了 Application 类型的 InformationProtectionPolicy.Read.All 权限,如下所示:
当我使用客户端凭证流生成的令牌使用
v1.0
端点运行 API 时,我也遇到了 同样的错误:
GET https://graph.microsoft.com/v1.0/users/{id}/security/informationProtection/sensitivityLabels
回复:
要解决该错误,请确保使用
/beta
端点,我在该端点成功获得了带有标签详细信息的响应,如下所示:
GET https://graph.microsoft.com/beta/users/{id}/security/informationProtection/sensitivityLabels
回复:
参考: