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

Microsoft Graph获取在线会议转录文件遇格式错误的解决咨询

问题描述

我在控制台应用中使用以下C#代码获取Teams会议转录文件:

var deviceCodeCredential = new DeviceCodeCredential(new DeviceCodeCredentialOptions
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
    ClientId = AzureClientID,
    TenantId = AzureTenantID,
    DeviceCodeCallback = (code, cancellation) =>
    {
        Console.WriteLine(code.Message);
        return Task.FromResult(0);
    }
});

var graphClient = new GraphServiceClient(deviceCodeCredential, 
    new[] { "User.Read", "OnlineMeetingTranscript.Read.All" });  
          
var meeting = await graphClient.Me.OnlineMeetings.GetAsync((requestConfiguration) =>
{
    requestConfiguration.QueryParameters.Filter = "joinWebUrl eq '" + TeamsURL + "'";
});

var transcript = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts.GetAsync();

var transcriptText = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts[transcript.Value[0].Id].Content.GetAsync((requestConfiguration) =>
{
    requestConfiguration.Headers.Add("Content-Type", "text/vtt");
});    

/*
官方文档建议这么写,但QueryParameters是DefaultQueryParameters类型,没有Format属性,代码无法编译

var transcriptText = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts[transcript.Value[0].Id].Content.GetAsync((requestConfiguration) =>
{
    requestConfiguration.QueryParameters.Format = "text/vtt";
});    
*/

运行时收到错误:

Invalid format 'application/octet-stream, application/json' specified.

尝试按官方文档设置Format参数失败,改用添加Content-Type请求头仍报错,请问如何解决,如何让Graph API返回application/octet-stream格式的输出?

解决方案

1. 替换请求头:用Accept指定返回格式

Content-Type用于告知服务器请求体的格式,而指定返回格式需要用Accept请求头。修改代码中的请求头设置:

var transcriptText = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts[transcript.Value[0].Id].Content.GetAsync((requestConfiguration) =>
{
    // 要获取application/octet-stream格式,就把值改成对应类型
    requestConfiguration.Headers.Add("Accept", "application/octet-stream");
});

2. 手动拼接格式查询参数

如果需要遵循文档中通过format参数指定格式的逻辑,可以直接在请求URL后拼接参数:

var transcriptText = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts[transcript.Value[0].Id].Content
    .WithUrl(url => url += "?format=application/octet-stream")
    .GetAsync();

3. 基础验证步骤

确保以下条件满足,避免其他潜在问题:

  • 应用已正确配置并获得OnlineMeetingTranscript.Read.All权限(租户级权限需完成管理员同意)
  • 目标会议已结束,只有结束后的会议才会生成可获取的转录文件
  • 代码中获取的会议ID、转录ID均有效,避免数组索引越界或引用错误资源

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 08:06:00