1

我正在按照 docusign rest api v2 第 93 页中的“发送信封或创建草稿信封”发送文档​​以供签名。

文档已发送并签名,但我在使用事件通知功能时遇到了问题。

我对此功能的 xml 结构有点困惑。我尝试了很多不同的组合,但我无法弄清楚。有什么帮助吗?

这是我尝试过的众多之一...

<eventNotification>
    <url>xxxxxx</url>
    <includeDocuments>false</includeDocuments>
    <loggingEnabled>true</loggingEnabled>
    <envelopeEvents>
        <envelopeEvent>
            <envelopeEventStatusCode>completed</envelopeEventStatusCode>
        </envelopeEvent>
    </envelopeEvents>
</eventNotification>
4

2 回答 2

2

Kim 说得对,DocuSign 目前没有很好的 XML 格式请求正文文档。然而,有时由于技术限制、您不想重新编写解析代码或其他原因,JSON 不是一个选项,并且开发人员被 XML 格式卡住了。

话虽如此,下面是eventNotifications对象的正确 XML 格式,以及您可以在其上设置的所有可能属性:

<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>
于 2013-10-29T16:57:38.033 回答
2

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>
于 2013-10-29T16:04:51.293 回答