Cloud Upload Template using Python

This example shows how to upload a template to the cloud using Python.  It calls the Docmosis REST API to upload a local template file to the cloud.

The sample code includes the instructions to get started. You will need a Free Trial and then plug your Docmosis Cloud access key into the code below, then run.

Note: This code sample is written to specifically work with DWS4.

# This example shows how to use Python to call the Docmosis Cloud service to upload a template.

import json
import requests
import datetime

# Set your region url here.
# End-point in the USA
URL = 'https://us1.dws4.docmosis.com/api/uploadTemplate'
# End-point in the EU
#URL = 'https://eu1.dws4.docmosis.com/api/uploadTemplate'
# End-point in AUS
#URL = 'https://au1.dws4.docmosis.com/api/uploadTemplate'

# Set your access key here. This is visible in your cloud account in the Docmosis Web Site.
# It is your key to accessing your service - keep it private and safe.
accessKey='XXX'

#Template to upload
templateName='myTemplate.docx'

if accessKey=='XXX':
  print("Please set your access key")
  exit()

files = {'templateFile': open(templateName, 'rb')}
fields = {"accessKey":accessKey, "templateName":templateName }

req = requests.post(URL, data=fields, stream=True, files=files)
print (req.text)
 

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input

Applies To

Docmosis-Java Tornado Cloud
Version(s) - - DWS4