You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Graph API查询communications/calls/{id}时遇UnknownError求助

调用Microsoft Graph API获取Teams通话信息时触发UnknownError的排查方案

问题描述

我使用以下代码调用Graph API获取Teams的通话信息,但持续触发UnknownError,不清楚问题所在:

代码示例

// The client credentials flow requires that you request the
// /.default scope, and preconfigure your permissions on the
// app registration in Azure. An administrator must grant consent
// to those permissions beforehand.
string[] scopes = new[] { "https://graph.microsoft.com/.default" };

// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
//string tenantId = "common";
string tenantId = AzureDetails.TenantID;

// Values from app registration
string clientId = AzureDetails.ClientID;
string clientSecret = AzureDetails.ClientSecret;

// using Azure.Identity;
TokenCredentialOptions options = new()
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
ClientSecretCredential clientSecretCredential = new(tenantId, clientId, clientSecret, options);

GraphServiceClient graphClient = new(clientSecretCredential, scopes);

call = await graphClient.Communications.Calls[id].Request().GetAsync();

异常信息

Code: UnknownError
Inner error:
    AdditionalData:
    date: 2022-08-30T17:11:46
    request-id: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2
    client-request-id: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2
ClientRequestId: b00e1f14-82d7-459b-bbdc-ae13ae04cdb2

排查与解决方法

  • 权限配置验证

    • 确认Azure应用注册已添加Calls.Read.All或Calls.ReadWrite.All应用权限,且已完成管理员同意(客户端凭证流不支持用户权限)。
    • 检查Azure门户中权限状态是否为“已授予”,未授权的权限会直接导致请求被拦截。
  • 通话ID有效性检查

    • 确认传入的id是当前租户内的有效通话ID,已结束超过30天的通话可能已被系统归档清理,建议用近期活跃的通话ID测试。
    • 核对通话ID格式,避免拼写、截断或复制错误。
  • SDK与API版本确认

    • 升级Microsoft Graph SDK到最新稳定版,旧版本可能存在身份验证逻辑或API兼容性问题。
    • 确保调用Graph API v1.0版本,beta版本功能不稳定,易触发未知错误。
  • 身份验证参数校验

    • 核对租户ID、客户端ID、客户端密钥的准确性,参数错误常被封装为UnknownError返回。
    • 检查客户端密钥是否过期,若过期需在Azure门户重新生成并更新代码配置。
  • 日志与请求追踪

    • 为GraphServiceClient添加日志拦截器,捕获完整的请求头、响应内容,挖掘底层错误细节。
    • 登录Azure门户查看Azure AD审核日志,通过request-id定位对应请求记录,获取更具体的失败原因。

内容的提问来源于stack exchange,提问作者novice_dev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 19:57:25