Getting error while uploading video on video indexer portal.

Shaveta Pujani 0 Reputation points
2023-03-20T12:38:32.7266667+00:00

Hi,

I am trying to upload a video on the Video Indexer portal through Indexer API but this is throwing the below error. The same URL is uploading the video on the indexer portal through Postman request

"ErrorType":"INVALID_INPUT","Message":"Value isn't valid URL of any kind, relative or absolute"

Code to upload the video:

   FileStream video = System.IO.File.OpenRead(url);
                byte[] buffer1 = new byte[video.Length];
                video.Read(buffer1, 0, buffer1.Length);
                content.Add(new ByteArrayContent(buffer1));
                var _url = $"{apiUrl}/{location}/Accounts/{accountId}/Videos?name=some_name&description=some_description&privacy=private&partition=some_partition";
                var uploadVideoRequest = new HttpRequestMessage(HttpMethod.Post, _url);
                uploadVideoRequest.Content = content;
                
                uploadVideoRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", GlobalVairables.AccountToken); 
                uploadVideoRequest.Headers.Add("x-ms-client-request-id", Guid.NewGuid().ToString()); 
                var uploadRequestResult = await client.SendAsync(uploadVideoRequest);
                var uploadResultJson = await uploadRequestResult.Content.ReadAsStringAsync();

Please let me know if I am missing anything.

Azure AI Video Indexer
Azure AI Video Indexer
An Azure video analytics service that uses AI to extract actionable insights from stored videos.
46 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 14,416 Reputation points
    2023-03-25T06:15:45.83+00:00

    Hi @Shaveta Pujani , Thanks for using Microsoft Q&A Platform.

    This error message shows that the URL value given is not a valid URL, either relative or absolute. Please check that the URL is properly formatted and that it is a valid URL. Here is the code to which you can compare.

    // Upload a video
                MultipartFormDataContent content = null;
                Console.WriteLine("Uploading...");
                content = new MultipartFormDataContent();
                FileStream video = File.OpenRead(@"c:\videos\democratic3.mp4");
                byte[] buffer = new byte[video.Length];
                video.Read(buffer, 0, buffer.Length);
                content.Add(new ByteArrayContent(buffer), "MyVideo", "MyVideo");
    
                var queryParams = CreateQueryString(
                    new Dictionary<string, string>()
                    {
                {"accessToken", accessToken},
                {"name", "video sample"},
                {"description", "video_description"},
                {"privacy", "private"},
                {"partition", "partition"},
                               });
                var uploadRequestResult = await client.PostAsync($"{apiUrl}/{accountLocation}/Accounts/{accountId}/Videos?{queryParams}", content);
                var uploadResult = await uploadRequestResult.Content.ReadAsStringAsync();
    
    

    here is the code sample document that demonstrates this: https://learn.microsoft.com/en-us/azure/azure-video-indexer/upload-index-videos?tabs=with-arm-account-account#code-sample

    also, GitHub sample code: https://github.com/Azure-Samples/media-services-video-indexer/blob/master/API-Samples/C%23/ArmBased/Program.cs

    Regards,
    Vasavi

    0 comments No comments