{"httpCode":400,"internalCode":3,"details":"Request entity too large."}

Hi, I am trying to upload a PDF that is 1.5mb and getting the above error. What am I doing wrong?
This is my python script:

import requests
session = requests.Session()

url = “https://api.vectara.io/v1/upload?c=CUSTOMER_ID&o=1

payload={}
files=[
(‘file’,(‘file’,open(‘/Users/path/to/file’,‘rb’),‘application/octet-stream’))
]
headers = {
‘Content-Type’: ‘multipart/form-data’,
‘Accept’: ‘application/json’,
‘x-api-key’: ‘API_KEY’
}

response = session.post(url, headers=headers, data=payload, files=files)

print(response.text)

session.close()

Thanks for your question. The following works fine. Can you please try it?

import requests
session = requests.Session()


files={
    "file": ("i1040gi.pdf", open("~/data/i1040gi.pdf", "rb"), "application/octet-stream")
}

post_headers = {
"x-api-key": API_KEY
}

response = session.post(
    url = f"https://api.vectara.io/v1/upload?c={CUSTOMER_ID}&o={CORPUS_ID}",
    headers=post_headers,
    files=files)

print(response.text)

session.close()

Thank you! Yes, this worked.
Looks like the headers weren’t necessary. Fwiw, the code I used was copied from the API Playground.

Thank you for the feedback @alexb ! I’ll look at why the API Playground is producing that and see if I can get it fixed

@shane I got the same error as the OP and this code also worked for me, whereas the code in the documentation did not. Curl worked without error. This code is different in several ways than the code in the documentation. It would be helpful to change the documentation