How do I resolve requests.exceptions.HTTPError: 424 Client Error Failed Dependency for url in Azure Video Indexer?

Hazra, Gourab 0 Reputation points
2024-07-20T03:22:40.66+00:00

This is the code I am using in Python to upload a video and search for frames using natural language. I understand that this code does not do the latter but I am getting an error message from before the default insights can be generated.

# imports
from dotenv import dotenv_values
from pprint import pprint

from VideoIndexerClient.Consts import Consts
from VideoIndexerClient.VideoIndexerClient import VideoIndexerClient

config = dotenv_values(".env")

AccountName = config.get('AccountName')
ResourceGroup = config.get('ResourceGroup')
SubscriptionId = config.get('SubscriptionId')

ApiVersion = '2024-01-01'
ApiEndpoint = 'https://api.videoindexer.ai'
AzureResourceManager = 'https://management.azure.com'

# create and validate consts
consts = Consts(ApiVersion, ApiEndpoint, AzureResourceManager, AccountName, ResourceGroup, SubscriptionId)

# Authenticate

# create Video Indexer Client
client = VideoIndexerClient()

# Get access tokens (arm and Video Indexer account)
client.authenticate_async(consts)
client.get_account_async()

# VideoUrl = 'YOUR_VIDEO_URL'
ExcludedAI = []

# video_id = client.upload_url_async('my-video-name', VideoUrl, ExcludedAI, False)

LocalVideoPath = 'water_damage_demo.mp4'
file_video_id = client.file_upload_async(LocalVideoPath, video_name=None, excluded_ai=ExcludedAI)
client.wait_for_index_async(file_video_id)
insights = client.get_video_async(file_video_id)
pprint(insights)

# client.get_insights_widgets_url_async(video_id, widget_type='Keywords')
# client.get_player_widget_url_async(video_id)

prompt_content = client.get_prompt_content(file_video_id)
pprint(prompt_content)

I have used the credentials for Accountname, Resourcegroup and subscription ID as per the resource group created from Azure Portal. This is the error I get. How do I resolve this?

[Account Details] Id:
Azure AI Video Indexer
Azure AI Video Indexer
An Azure video analytics service that uses AI to extract actionable insights from stored videos.
86 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amanulla Asfak Ahamed 155 Reputation points
    2024-07-20T03:29:31.6933333+00:00
    1. Dependency on Access Tokens or Other API Calls: Ensure that all prerequisite steps like authentication and token retrieval have completed successfully. If any prior step in the API interaction fails (like obtaining an access token), subsequent requests will fail.
      **Authentication**:
      
      • Confirm that the method for retrieving access tokens is correct and returns a valid token without errors. Tokens are essential for authorizing your requests to the Video Indexer API.
      • Check that your environment variables (like AccountName, ResourceGroup, SubscriptionId) are correctly set in your .env file and are being correctly read into your Python script.
      Validating Tokens:
      • Once you receive an access token, ensure it is not expired and is applicable for the type of requests you are making. Sometimes tokens have scope or permission limitations.
      • Implement error handling around token acquisition to catch and manage any failures or invalid responses immediately.
      Sequential Dependency:
      • API calls often need to be made in a specific sequence. For example, you must authenticate and retrieve a token before making a request to upload a video. Make sure your code respects these dependencies.
      • Use asynchronous or callback structures appropriately to handle dependencies between calls, ensuring that a subsequent API call does not attempt to execute before its prerequisite call has successfully completed.
      Debugging and Logging:
      • Add logging at critical steps to capture the status of each API call. This can help identify the step at which the process fails.
      • For debugging purposes, you might also manually perform each step using tools like Postman or a similar API client to isolate the problem.
    2. Incorrect or Missing API Parameters: Double-check all parameters being sent in the failing request. This includes checking whether the correct accessToken, accountID, and other required parameters are correctly configured and valid at the time of the request.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.