使用Microsoft Graph API创建日历事件时遭遇ODataError:邮箱处于非活跃、软删除或本地托管状态
Microsoft Graph API创建日历事件时遭遇ODataError:邮箱处于非活跃、软删除或本地托管状态
我最近尝试用Microsoft Graph API创建日历事件,但调用接口时收到了这样的错误返回:
com.microsoft.graph.models.odataerrors.ODataError: The mailbox is either inactive, soft-deleted, or is hosted on-premise.
以下是我的相关代码实现:
private String postCalendarEventForClients(Event event, TeamsCalendarCreateRequestDTO requestDTO) { String caluid = requestDTO.getICalUId() == null ? "NaN" : requestDTO.getICalUId(); UserCollectionResponse usrs = graphClient.users().get(); for (User usr : usrs.getValue()) { } for (String clientEmail : requestDTO.getClientEmails()) { Event createdEvent = graphClient.users().byUserId(user.getMail()).events().post(event); } return caluid; } @Bean public GraphServiceClient graphServiceClient() { // Create an authentication provider for Microsoft Graph API final ClientSecretCredential credential = new ClientSecretCredentialBuilder() .clientId(clientId).tenantId(tenantId).clientSecret(clientSecret).build(); // Initialize and return Graph client return new GraphServiceClient(credential, scopes.toArray(new String[0])); }
我的应用权限配置如下:
(截图内容:已勾选Calendars.ReadWrite、User.Read.All等应用级权限,权限状态显示为已授予)
另外还有个奇怪的情况:这个用户已经在Microsoft 365管理中心被分配了Office 365 Standard许可证,我手动登录该用户账号能正常访问日历并创建事件,但在Azure门户的「用户-许可证」页面里,却看不到任何已分配的许可证:
- Azure用户许可证页面截图:显示该用户无任何许可证记录
- Microsoft 365管理中心截图:已明确为该用户分配Office 365 Standard许可证
备注:内容来源于stack exchange,提问作者Patrik




