sohansp

Internal Server Error While Uploading Document in Python Rest

0 votes

Hi,

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

0 votes

headers = {

 

    '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

0 votes

Hi 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

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off