Код: Выделить всё
using System;
using System.Net.Http;
using System.Threading.Tasks;
class TranscriptService
{
static async Task Main(string[] args)
{
string url = "https://commcenterdev.azurewebsites.net/phoneCalls/";
// Replace with your actual API Key and Tenant ID.
string callId = "CALL_ID_HERE";
string apiKey = "API_KEY_HERE";
string tenantId = "TENANT_ID_HERE";
using (HttpClient client = new HttpClient())
{
try
{
// Set the required headers.
client.DefaultRequestHeaders.Add("phoneCalls", callId);
client.DefaultRequestHeaders.Add("API-Key", apiKey);
client.DefaultRequestHeaders.Add("Tenant-Id", tenantId);
// Send a GET request to the specified URL.
HttpResponseMessage response = await client.GetAsync(url);
// Ensure the request was successful.
response.EnsureSuccessStatusCode();
// Read the response content as a string.
string transcript = await response.Content.ReadAsStringAsync();
// Output the content to the console.
Console.WriteLine("Transcript:");
Console.WriteLine(transcript);
}
catch (HttpRequestException e)
{
// Handle any errors that occurred during the request.
Console.WriteLine("Error fetching the transcript: " + e.Message);
}
}
}
}
берёт базовый URL-адрес, идентификатор вызова, ключ API и идентификатор клиента и создаёт новый https-запрос. Затем он отправляет его в Интернет и ждет успешного выполнения запроса, а если нет, перехватывает исключение и выводит сообщение. Пожалуйста, дайте мне знать, если я все правильно понял.
Я просто ввожу в строки callId, apiKey и tenantId, но он просто возвращает 401.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ranscripts