Question

I'm sending a document for signature following "Send an Envelope or Create a Draft Envelope" in the docusign rest api v2, page 93.

The document gets sent and signed, but I'm having a problem with the event notification feature.

I'm a little confused about the xml structure for this feature. I've tried a lot of different combinations, but I can't figure it out. Any help?

This is one of the many I tried...

<eventNotification>
    <url>xxxxxx</url>
    <includeDocuments>false</includeDocuments>
    <loggingEnabled>true</loggingEnabled>
    <envelopeEvents>
        <envelopeEvent>
            <envelopeEventStatusCode>completed</envelopeEventStatusCode>
        </envelopeEvent>
    </envelopeEvents>
</eventNotification>
Était-ce utile?

La solution

Kim is right in that DocuSign currently does not have good documentation for XML formatted request bodies. However sometimes JSON is not an option due to technical limitations, you don't want to re-write parsing code, or other reasons, and developers are stuck with XML format.

With that said, here is the proper XML format for the eventNotifications object, along with all the possible properties you can set on it:

<eventNotification>
   <EnvelopeEvents>
      <envelopeEvent>
         <envelopeEventStatusCode>sample string 1</envelopeEventStatusCode>
         <includeDocuments>sample string 2</includeDocuments>
      </envelopeEvent>
      <envelopeEvent>
         <envelopeEventStatusCode>sample string 1</envelopeEventStatusCode>
         <includeDocuments>sample string 2</includeDocuments>
      </envelopeEvent>
   </EnvelopeEvents>
   <includeCertificateWithSoap>sample string 6</includeCertificateWithSoap>
   <includeDocuments>sample string 8</includeDocuments>
   <includeEnvelopeVoidReason>sample string 9</includeEnvelopeVoidReason>
   <includeSenderAccountAsCustomField>sample string 11</includeSenderAccountAsCustomField>
   <includeTimeZone>sample string 10</includeTimeZone>
   <loggingEnabled>sample string 2</loggingEnabled>
   <recipientEvents>
      <recipientEvent>
         <includeDocuments>sample string 2</includeDocuments>
         <recipientEventStatusCode>sample string 1</recipientEventStatusCode>
      </recipientEvent>
      <recipientEvent>
         <includeDocuments>sample string 2</includeDocuments>
         <recipientEventStatusCode>sample string 1</recipientEventStatusCode>
      </recipientEvent>
   </recipientEvents>
   <requireAcknowledgment>sample string 3</requireAcknowledgment>
   <signMessageWithX509Cert>sample string 7</signMessageWithX509Cert>
   <soapNameSpace>sample string 5</soapNameSpace>
   <url>sample string 1</url>
   <useSoapInterface>sample string 4</useSoapInterface>
</eventNotification>

Autres conseils

Although technically speaking, the DocuSign REST API supports both XML format and JSON format, a majority of the DocuSign REST API documentation, code samples, and developer resources are in JSON. Unfortunately that means trying to use XML format with the DocuSign REST API (to do anything beyond the very basic tasks) can be extremely frustrating -- because when your XML request doesn't work as expected, you have virtually no resources to figure out what the correct format is.

For that reason, I'd recommend that you consider using JSON instead of XML with the DocuSign REST API. Here's a JSON request that successfully creates the notification for the envelope.

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
  "templateId": "TEMPLATE_ID",
  "templateRoles": [
   {
      "roleName": "Signer1",
      "name": "John Doe",
      "email": "johnsemail@outlook.com"
    }
  ],
  "eventNotification":       {
    "url": "http://www.google.com",
    "loggingEnabled": "true",
    "requireAcknowledgement": "true",
    "includeDocuments" : "false",
    "envelopeEvents" : [{
      "envelopeEventStatusCode" : "completed"     
    }]
  },
  "status": "sent"
}

UPDATE: Using information provided by Ergin below, I was able to get this to work using XML -- the key is to use uppercase for both 'Envelope' and 'Events' in the EnvelopeEvents element. Here's an example of a request that successfully triggers the Connect notification:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
   <accountId>ACCOUNT_ID</accountId>
   <status>sent</status>
   <templateId>TEMPLATE_ID</templateId>
   <templateRoles>
      <templateRole>
         <email>johnsemail@outlook.com</email>
         <name>John Doe</name>
         <roleName>Signer1</roleName>
      </templateRole>
   </templateRoles>
   <eventNotification>
    <EnvelopeEvents>
      <envelopeEvent>
        <envelopeEventStatusCode>completed</envelopeEventStatusCode>
      </envelopeEvent>
    </EnvelopeEvents>
    <includeDocuments>false</includeDocuments>
    <loggingEnabled>true</loggingEnabled>
    <requireAcknowledgement>true</requireAcknowledgement>
    <url>http://www.google.com</url>
   </eventNotification>
</envelopeDefinition>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top