如何将视频发布到视频索引器“https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns”的端点。
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "mykey");
// Request parameters
queryString["name"] = "name";
queryString["privacy"] = "Private";
var uri = "https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns?" + queryString;
HttpResponseMessage response;
// Request body
using (var content = new MultipartFormDataContent())
{
content.Add(new StreamContent(File.Open(@"file", FileMode.Open)), "file", "filename");
try
{
response = await client.PostAsync(uri, content);
Console.WriteLine(response);
}
catch (Exception e)
{
}
}
}
我收到“任务已取消”异常。请帮忙。
当我使用 videourl 时,API 工作正常
最佳答案
这是因为在尝试上传时,我的请求超时。
我添加
client.Timeout = TimeSpan.FromMinutes(30);
现在已经修复了。
关于c# - 如何通过api调用将视频上传到Microsoft Video Indexer(麦克风认知服务api)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44236982/