I'm trying to do a POST request using Python and the request library to this endpoint: https://cris.ai/swagger/ui/index#/Custom%20Speech%20datasets%20for%20model%20adaptation%3A/UploadDataset
Here's the code I'm using:
import requests
import json
from api_key import getApiKey, Ocp_Apim_Subscription_Key
url = 'https://westus.cris.ai/api/speechtotext/v2.0/datasets/upload'
payload = {
"name": "leo's try",
"description": "a dataset",
"locale": "en-US",
"dataImportKind": "Language"
}
files = {
"leo.txt;": open('leo.txt', 'rb')
}
api_key = getApiKey().decode()
# Adding empty header as parameters are being sent in payload
headers = {"Content-Type": "multipart/form-data","accept": "application/json","Ocp-Apim-Subscription-Key": Ocp_Apim_Subscription_Key,
"Authorization": api_key }
r = requests.post(url, files=files,data=payload, headers=headers)
print((r.content).decode())
Even though I've specified the Content-Type as multipart/form-data and added accept: application/json, the response comes back as an error:
{"code":"UnsupportedMediaType","message":"The request entity's media type 'application/xml' is not supported for this resource."}
Does anyone know what I should do?