好的,我在控制台应用程序中使用了以下 C# 代码:
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");
});
/*
API Docuementation suggests I do this: https://learn.microsoft.com/en-us/graph/api/calltranscript-get?view=graph-rest-1.0&tabs=csharp#example-2-get-a-calltranscript-content
However the "QueryParameters" returned is of type "DefaultQueryParameters"(which appears to be empty), so the for "Format" property does exist and the code won't build
var transcriptText = await graphClient.Me.OnlineMeetings[meeting.Value[0].Id].Transcripts[transcript.Value[0].Id].Content.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Format = "text/vtt";
});
*/
但是,当我运行此命令而不是接收成绩单时,我收到以下错误:
指定的格式“application/octet-stream、application/json”无效。
我该如何解决这个问题,如何指示图形 API 期望 API 输出“应用程序/八位字节流”。
最初,当我在我的环境中运行您的代码以获取通话记录内容时,我也遇到了同样的错误:
要解决该错误,请使用下面的modified代码,该代码在控制台中提供在线会议记录内容,如下所示:
using System.Text;
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models.ODataErrors;
namespace MSOnlineMeeting
{
class Program
{
static async Task Main(string[] args)
{
var scopes = new[] { "User.Read", "OnlineMeetingTranscript.Read.All", "OnlineMeetings.Read" };
var AzureTenantID = "tenantId";
var AzureClientID = "appId";
var options = new DeviceCodeCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
ClientId = AzureClientID,
TenantId = AzureTenantID,
DeviceCodeCallback = (code, cancellation) =>
{
Console.WriteLine(code.Message);
return Task.FromResult(0);
},
};
var deviceCodeCredential = new DeviceCodeCredential(options);
var graphClient = new GraphServiceClient(deviceCodeCredential, scopes);
try
{
var meetings = await graphClient.Me.OnlineMeetings.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "joinWebUrl eq 'URL'";
});
if (meetings.Value.Count == 0)
{
Console.WriteLine("No meetings found.");
return;
}
var meetingId = meetings.Value[0].Id;
var transcripts = await graphClient.Me.OnlineMeetings[meetingId].Transcripts.GetAsync();
if (transcripts.Value.Count == 0)
{
Console.WriteLine("No transcripts found.");
return;
}
var transcriptId = transcripts.Value[0].Id;
var transcriptContentStream = await graphClient.Me.OnlineMeetings[meetingId].Transcripts[transcriptId].Content.GetAsync((requestConfiguration) =>
{
requestConfiguration.Headers.Add("Accept", "text/vtt");
});
using (var memoryStream = new MemoryStream())
{
await transcriptContentStream.CopyToAsync(memoryStream);
string transcriptText = Encoding.UTF8.GetString(memoryStream.ToArray());
Console.WriteLine(transcriptText);
}
}
catch (ODataError odataError)
{
Console.WriteLine($"Error Code: {odataError.Error.Code}");
Console.WriteLine($"Error Message: {odataError.Error.Message}");
}
}
}
}
回复: