Reputation: 89
How to post video to endpoint of the videoindexer "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)
{
}
}
}
I am getting "A Task was canceled" exception. Please help.
The api works fine when i am using videourl
Upvotes: 1
Views: 553
Reputation: 89
It was because while trying to upload, my request was getting timed out.
I added
client.Timeout = TimeSpan.FromMinutes(30);
and now it's fixed.
Upvotes: 3