0
votes

I'm attempting to Request a signature using the DocuSign API via Javascript. Below is the multipart request that I'm sending. The problem is that I'm receiving an error response: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Envelope definition missing." Clearly, I'm including the "envelopeDefinition" xml in my request, and I'm pretty sure all the required elements are there. Any guidance would be greatly appreciated.

--BOUNDARY--
Content-Type: application/xml
Content-Disposition: form-data

<envelopeDefinition xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.com/restapi"><emailSubject>Test Subject</emailSubject><documents><name>document.pdf</name><documentId>1</documentId></documents><recipients><signers><tabs><signHereTabs><pageNumber>1</pageNumber><documentId>1</documentId><xPosition>100</xPosition><yPosition>100</yPosition></signHereTabs></tabs><routingOrder>1</routingOrder><recipientId>1</recipientId><name>My Name</name><email>[email protected]</email></signers></recipients><status>sent</status></envelopeDefinition>

--BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="document.pdf"; documentId=1 

[document bytes go here]

--BOUNDARY--

Also, I should mention I'm using Msxml2.XMLHTTP.

1

1 Answers

0
votes

Without also seeing the Request Headers, I can't say for absolute certain what your issue is. But, here are a couple of suggestions:

First, it seems like your XML request body is missing a couple of elements.

  • Add a <document> element as a child element of <documents> (i.e., encapsulating the name and documentId elements for the document)

  • Add a <signHereTab> element as a child element of <signHereTabs> (i.e., encapsulating the pageNumber, documentId, xPosition, and yPosition elements for the tab)

Once you make these additions to the XML, your request should look more like this:

POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1

X-DocuSign-Authentication: {"Username":"USERNAME","Password":"PASSWORD","IntegratorKey":"INTEGRATOR_KEY"}
Content-Type: multipart/form-data; boundary=BOUNDARY
Accept: application/xml
Host: demo.docusign.net
Content-Length: 23414
Expect: 100-continue
Connection: Keep-Alive

--BOUNDARY
Content-Type: application/xml
Content-Disposition: form-data

<envelopeDefinition xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.com/restapi">
    <emailSubject>Test Subject</emailSubject>
    <documents>
      <document>
        <name>document.pdf</name>
        <documentId>1</documentId>
      </document>
    </documents>
    <recipients>
        <signers>
            <tabs>
                <signHereTabs>
                  <signHereTab>
                    <pageNumber>1</pageNumber>
                    <documentId>1</documentId>
                    <xPosition>100</xPosition>
                    <yPosition>100</yPosition>
                  </signHereTab>
                </signHereTabs>
            </tabs>
            <routingOrder>1</routingOrder>
            <recipientId>1</recipientId>
            <name>My Name</name>
            <email>[email protected]</email>
        </signers>
    </recipients>
    <status>sent</status>
</envelopeDefinition>

--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="document.pdf"; documentid="1"

[document bytes removed]

--BOUNDARY--

Secondly, it looks like you're using the term BOUNDARY as your part-delimiter within the request -- but you're incorrectly using it like this in all three locations: --BOUNDARY--. As shown in the example request that I've included above, the first two instances of the delimiter should only have the -- (hyphens) preceding the word BOUNDARY, like this:

--BOUNDARY

Only the final occurrence of the delimiter (at the very end of the request) should have both leading AND trailing hyphens:

--BOUNDARY--