API ZohoBooks expenses upload receipt PDF
Hi,
I have by now tried a whole bunch of different ways to upload a pdf file as a receipt for an expense but until now I am failing miserably. My code in Python is currently:
------
headers = {
"Authorization" : "Zoho-oauthtoken {token}"
"Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8"
}
files = {'receipt': open(filename, 'rb')}
url = 'https://books.zoho.com/api/v3/expenses/{expense_id}/receipt?organization_id=682930734'
r = requests.post(url, headers=headers, files=files)
------
This gives me
<Response [400]>
{"code":15,"message":"Please ensure that the --b65b8f9ff3618fe382b1ec9ab315f0bc\r\nContent-Disposition: form-data; name has less than 100 characters."}
-------
instead of 'files = .... ' I have also tried:
params = [{
'receipt': open(filename, 'rb'),
'file_name': filename
}]
-------
That gives me:
<Response [201]>
{"code": 0,"message": "The expense receipt has been attached."}
But then my receipt does not actually show up in ZohoBooks.
Can someone help me?
Thank you