2

我正在尝试使用 Python 中的 VideoIndexer API 从本地机器上传视频文件。我希望将视频作为多部分/表单正文内容上传。以下是我的代码(下面未粘贴 accountID、名称、位置等变量值),

# 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))

我收到以下错误,

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

我该如何解决这个问题?

4

0 回答 0