我需要帮助创建访问审查。这里的示例代码似乎是旧的https://learn.microsoft.com/en-us/graph/api/accessreviewset-post-definitions?view=graph-rest-1.0&tabs=csharp#request
但是在代码中.PostAsync不可用
下面是我的更新代码:但是运行下面的代码,我得到了这个错误:消息:PartnerData|存储库中未找到ID为0000000 - 0000 - 0000 - 0000- 00000000000的合作伙伴记录
Console.WriteLine($"Creating AR for Group {groupid}");
var ar = new AccessReviewScheduleDefinition();
ar.DisplayName = "One-time self-review for members of Building security";
ar.DescriptionForAdmins = "One-time self-review for members of Building security";
ar.DescriptionForReviewers = "One-time self-review for members of Building security";
ar.Scope = new AccessReviewScope
{
AdditionalData = new Dictionary<string, object>
{
{
///transitiveMembers - Self Review
"query" , $"/groups/{groupid}/owners"
},
{
"queryType" , "MicrosoftGraph"
},
},
};
ar.InstanceEnumerationScope = new AccessReviewScope
{
AdditionalData = new Dictionary<string, object>
{
{
"query" , $"/groups/{groupid}"
},
{
"queryType" , "MicrosoftGraph"
},
},
};
ar.Settings = new AccessReviewScheduleSettings
{
MailNotificationsEnabled = true,
ReminderNotificationsEnabled = true,
JustificationRequiredOnApproval = true,
DefaultDecisionEnabled = true,
DefaultDecision = "Deny",
InstanceDurationInDays = 5,
AutoApplyDecisionsEnabled = true,
RecommendationsEnabled = true,
Recurrence = new PatternedRecurrence
{
Pattern = new RecurrencePattern
{
Type = RecurrencePatternType.Weekly,
Interval = 1,
},
Range = new RecurrenceRange
{
Type = RecurrenceRangeType.NoEnd,
StartDate = new Date(2023,03,15),
},
},
};
try
{
var result = await graphClient.IdentityGovernance.AccessReviews.Definitions.Request().AddAsync(ar);
Console.WriteLine(result);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
我尝试了文章上的代码,但后来修改为上面的代码
1条答案
按热度按时间lymnna711#
我尝试了下面的代码来创建访问审查与客户端凭据身份验证,它被成功创建,参考下面:-
代码:-
输出:-
当我运行你的代码时,我也收到了相同的错误代码,当我在我的代码中将我的查询组参数从transitiveMember更改为Owners时,我得到了相同的错误,参考如下:-
当您没有遵循MS Graph文档中的默认SDK方法并使用错误的参数进行自我审查时,会发生此错误。您的代码缺少OdataType,并且Reviewers函数应包含此方法:-
Odata类型:-
审稿人:-
我在下面的代码中尝试了上面的参数,它工作了。我将AccessReviewReviewerScope添加到Owner:-
输出:-
请确保检查本文档中的有效和支持的参数:-
参考资料:-
Create definitions - Microsoft Graph v1.0 | Microsoft Learn
Assign reviewers to your access review using the Microsoft Graph API - Microsoft Graph | Microsoft Learn