Uploading PDF Files via API to Dustt Agent: SSL Error Troubleshooting
Hi, In a use case at Aramisauto, I'm trying to upload a PDF file via the API to then use it with a Dustt Agent. I have no problem obtaining an upload URL:
import requests
import os
# 1. Upload the file
file_size_in_bytes = int(os.path.getsize(filename))
upload_response = requests.post(
f"https://dust.tt/api/v1/w/{wId_dust}/files",
headers={"Authorization": f"Bearer {api_key_dust}"},
json={
"contentType": "application/pdf",
"fileName": os.path.basename(filename),
"fileSize": file_size_in_bytes,
"useCase": "conversation",
},
)
print(upload_response.status_code)
B
However, when uploading the file to this upload URL, I encounter an SSL URL error:
requests.exceptions.SSLError: HTTPSConnectionPool(host='dust.tt', port=443): Max retries exceeded with url: /api/v1/w/8ee268e693/files/fil_gXHmJOIvCGbz (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2426)')))
o
I don't see this part in the Dustt API documentation. Could you please indicate what the problem might be?
upload_url = upload_response.json()["file"]["uploadUrl"]
sess = requests.Session()
with open(filename, 'rb') as f:
resp = sess.post(
upload_url,
data=f.read(),
headers={"Authorization": f"Bearer {api_key_dust}"}, # Do not include additional headers here
)
print(resp.text)
n