Handling Large Documents
If you have a very large document that is difficult to upload, you can break it into several smaller documents, upload those, and then merge them into a single document. You use the /documents/merge endpoint to create the merged document.
In order to merge documents, you will need to know the documentID of each of the documents you wish to combine, and you will need to ensure that they are all the same size. The /documents/merge endpoint creates a new document that will be stored in your account and can be used like any other document.
# Load the HTTP requests module
import requests
# Define the endpoint to use
url = "https://stage-rest.click2mail.com/molpro/documents/merge"
# Define credentials
myusername = 'awesomeuser'
mypassword = 'gReAt/PaSsWoRd123'
headers = {
"Accept": "application/xml",
"Content-Type": "application/xml",
"user-agent": "my-app/0.0.1"
}
# Build the XML block containing the documentIds to combine
body = (
'<documentList>'
'<documentId>542625</documentId>'
'<documentId>470100</documentId>'
'</documentList>'
)
# Give the new document a name
documentName='MyNewDocument'
# Add document name to the url as a query parameter
url = url + '?documentName=' + documentName
# Make the POST call
r = requests.post(url, data=body, headers=headers, auth=(myusername, mypassword))
# Display the result - a success should return status_code 201
print(r.status_code)
# Display the full XML returned.
print(r.text)
If the call is successful, you should receive an HTTP 201 code, and an XML body that includes the documentId of the newly-created document:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<document>
<id>542626</id>
<status>0</status>
<description>Success</description>
</document>
Updated 7 months ago