…does nerdy things.

Python and the DocuSign API

Filed under: Work — Bryan on Nov 4th, 2011 @ 10:36 am

SOAP is a bit foreign to me (JSON + good documentation seems so much easier), but I finally managed to authenticate DocuSign with a SOAP client in Python. The code below assumes you have a developer account all set up and have suds, the Python SOAP library, installed:

from suds.client import Client
 
class DocuSign(Client):
    """
    Create a preloaded suds client.
    """
    def __init__(self, username, password, integrator_key, demo=False):
 
        url = 'https://%s.docusign.net/api/3.0/schema/dsapi.wsdl' % 'demo' if demo else 'www'
        location = 'https://%s.docusign.net/api/3.0/dsapi.asmx' % 'demo' if demo else 'www'
        auth = {
            'X-DocuSign-Authentication': '<DocuSignCredentials>' +
                ('<Username>%s</Username>' % username) +
                ('<Password>%s</Password>' % password) +
                ('<IntegratorKey>%s</IntegratorKey>' % integrator_key) +
            '</DocuSignCredentials>'}
 
        super(DocuSign, self).__init__(url, location=location, headers=auth)
 
client = DocuSign(
    username='me@example.com', 
    password='secret', 
    integrator_key='FOOO-6deb3ff9-5479-1241-9287-11f4919c7417', 
    demo=True)
 
print client.service.Ping()

Just follow the DocuSign documentation and suds documentation!

0 Comments »

No comments yet.

Leave a comment

All articles are licensed under a Attribution-Noncommercial-Share Alike 3.0 Unported License. All files/themes are released under the GPL License where applicable. © 2012 Bryan Helmig Hosted on Webfaction.