0

I am following the Docusign guide to upload PDF for signing. I get the error message NO_DOCUMENT_RECEIVED. Can you guide me on what could be causing this ? I am using JDK 8/Win 7/64bit and IDE is Netbeans 7.0.0.1

TIA ! Ruben.

Here is a trace log:

Info:   ***** IN SIGN DOCUMENT *****
Info:   ***** IN DOCUSIGN AUTHENTICATION *****
Info:   STEP 1:  Sending Login request...
Info:   ***** BASEURL:https://demo.docusign.net/restapi/v2/accounts/1323921 *****
Info:   ***** accountID:1323921 *****
Info:   ***** IN CREATE ENVELOPE *****
Info:   -- Login response --
<?xml version="1.0" encoding="UTF-8"?><loginInformation xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <loginAccounts>
    <loginAccount>
      <accountId>1323921</accountId>
      <baseUrl>https://demo.docusign.net/restapi/v2/accounts/1323921</baseUrl>
      <email>MYEMAIL@ABC.COM</email>
      <isDefault>true</isDefault>
      <name>COMPANY</name>
      <siteDescription/>
      <userId>23fffd08-d461-4a12-b3e4-8a6528dd2a69</userId>
      <userName>Ruben</userName>
    </loginAccount>
  </loginAccounts>
</loginInformation>
Info:   ***** IN SEND CONTRACT *****
Info:   SIZE IN BYTES : 513625
Info:   ***** request body start *****
Info:   
--BOUNDARY
Content-Type: application/xml
Content-Disposition: form-data
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
    <emailSubject>API Call for adding signature request to document and sending</emailSubject>
    <status>sent</status>
    <documents>
        <document>
            <documentBase64></documentBase64> //inserting length of packet (513625) throws invaild size message here
            <documentId>1</documentId>
            <name>ERS.pdf</name>
        </document>
    </documents>
    <recipients>
        <signers>
            <signer>
            <recipientId>1</recipientId>
            <name>Ruben</name>
            <email>MYEMAIL@ABC.COM</email>
            <tabs>
                <signHereTabs>
                    <signHere>
                        <xPosition>175</xPosition>
                        <yPosition>122</yPosition>
                        <documentId>1</documentId>
                        <pageNumber>12</pageNumber>
                    </signHere>
                </signHereTabs>
            </tabs>
            </signer>
        </signers>
    </recipients>
</envelopeDefinition>
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="ERS.pdf"; documentid="1"

Info:   [B@50ce7292
Info:   
--BOUNDARY--

Info:   ***** request body end *****
Info:   API call failed, status returned was: 400
Info:   Error description:  
<?xml version="1.0" encoding="UTF-8"?><errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <errorCode>NO_DOCUMENT_RECEIVED</errorCode>
  <message>The document element did not contain the encoded document, or there is a problem with the encoding. Bytes for document corresponding to documentId 1 not found in request. 'documentId=&lt;x&gt;' possibly missing from Content-Disposition header.</message>
</errorDetails>

1 Answers1

0

Rewrite the default initializeRequest for handling mutipart uploads so just before upload change the multipart value to true in all other cases such as login set it to false.

private static HttpURLConnection initializeRequest(String url, String method,
            String body, String httpAuthHeader, Boolean multipart) {
        HttpURLConnection conn = null;
try {
            conn = (HttpURLConnection) new URL(url).openConnection();

            conn.setRequestMethod(method);
            conn.setRequestProperty("X-DocuSign-Authentication", httpAuthHeader);
            conn.setRequestProperty("Accept", "application/xml");
            conn.setDoOutput(true);
            if (multipart) {
                conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=BOUNDARY");
            } else {
                conn.setRequestProperty("Content-Type", "application/xml");
                if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT") || method.equalsIgnoreCase("DELETE")) {
                    conn.setRequestProperty("Content-Length", Integer.toString(body.length()));
                    DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
                    dos.writeBytes(body);
                    dos.flush();
                    dos.close();
                }
            }
            return conn;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }