W.r.t File Upload API Documentation it works fine on postman but the python equivalent code (auto generated by postman) was throwing 500 error.
This is just to share with the community that though this is NOT a Kore.ai platform issue, the code auto-generated may have a problem with the header. Refer this external resource
Remove the highlighted header above - ‘Content-Type’: ‘multipart/form-data’ and the code snippet worked fine.
Below is a working code.
import requests
url = “https://bots.kore.ai/api/public/uploadfile”
payload={
'fileContext': 'bulkImport',
'fileExtension': 'json'
}
files={(‘file’,(‘uploadtest.json’,open(‘D:/dev/uploadtest.json’,‘rb’),‘application/json’))}
headers = {
‘auth’: ‘eyXXXXXXXXXXXXXXXXXXXXXXXs’
}
response = requests.request(“POST”, url, headers=headers, data=payload, files=files)
print(response.text)
output: