DocuSign NO_DOCUMENT_RECEIVED

时间:2015-12-01 14:38:08

标签: document sign docusignapi demo

我正在关注Docusign指南上传PDF以进行签名。我收到错误消息NO_DOCUMENT_RECEIVED。你能指导一下导致这种情况的原因吗?我使用的是JDK 8 / Win 7 / 64bit,IDE是Netbeans 7.0.0.1

TIA! 鲁

以下是跟踪日志:

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 个答案:

答案 0 :(得分:0)

重写默认的initializeRequest以处理多部分上传,因此在上传之前,在其他所有情况下将multipart值更改为true,例如login将其设置为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);
        }
    }