2

I am trying to upload a video file from local machine using VideoIndexer API in Python. I am expected to upload video as a multipart/form body content. Following is my code (Variable values like accountID, name, location are not pasted below),

# Request headers
headers = { 
    'x-ms-client-request-id': '',
    'Content-Type': 'multipart/form-data',
    'Ocp-Apim-Subscription-Key': 'xxxxxxxxx',
}

# Request parameters
params = urllib.parse.urlencode({      
    'privacy': 'Private',
    'description': 'testing',
}) 

try:
    conn = http.client.HTTPSConnection('api.videoindexer.ai')
    conn.request("POST", "/" + location + "/Accounts/" + accountId + "/Videos?name=" + name + "&accessToken=" + accessToken + "&%s" % params, body = open('TestAudio1.mp4', 'rb').read(), headers = headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
    
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

I am getting the following error,

{"ErrorType":"INVALID_INPUT","Message":"Input is invalid. Input must specify either a video url, an asset id or provide a multipart content body."}

How can I fix this issue?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Gagan G
  • 31
  • 1
  • see https://stackoverflow.com/questions/47192872/how-to-upload-a-video-file-using-python-in-video-indexer-api – oriziv Feb 18 '21 at 07:58

0 Answers0