Internal Server Error While Uploading Document in Python Rest
Thursday, August 27, 2020 at 06:55amHi,
I was trying the below code snipped
To upload documents to packages,
headers = {
'accept': 'text/html; esl-api-version=11',
'Content-Type': 'multipart/form-data',
'Authorization': 'Bearer {}'.format(token["accessToken"]),
}
files = {
'file': ('sample.pdf', open('sample.pdf', 'rb').read()),
'type':"application/pdf"
}
values = {'payload': '{"name":"NDA Document"}'}
package_id = "xxxsomepackage_id="
url = "https://sandbox.esignlive.com/api/packages/{}/documents".format(package_id)
response = requests.post(url, headers=headers, files=files, data=values)
print(response.text)
Output
<html><head><title>Error</title></head><body>Internal Server Error</body></html>
Help Needed
Reply to: Internal Server Error While Uploading Document in Python Rest
Thursday, August 27, 2020 at 07:20amheaders = {
'Authorization': 'Bearer {}'.format(token["accessToken"]),
}
files = {
'file': open('sample.pdf', 'rb'),
'payload': '{"name":"NDA Document"}'
}
package_id = "*****="
url = "https://sandbox.esignlive.com/api/packages/{}/documents".format(package_id)
response = requests.post(url, headers=headers, files=files)
print(response.text)
This worked,
Removed
'Content-Type': 'multipart/form-data',
in header
Reply to: Internal Server Error While Uploading Document in Python Rest
Thursday, August 27, 2020 at 09:35amHi there,
Glad to hear you've found the answer! To leverage the REST API with python, below examples in code share might also help:
Create And Send Package in Python (REST API): https://community.onespan.com/documentation/onespan-sign/codeshare/create-and-send-package-python-rest-api
eSignLive REST Client using Python: https://community.onespan.com/documentation/onespan-sign/codeshare/esignlive-rest-client-using-python
Also feel free to make other posts if you hit any issues!
Duo