簡體   English   中英

將文檔添加到現有信封

[英]Add documents to existing envelope

我正在遵循https://www.docusign.com/blog/dsdev-using-docusign-rest-api-add-additional-documents-envelope/上的(第3課),僅將其他文檔添加到我現有的信封草稿中我正在使用nodejs模塊http://docusign.github.io/docusign-node-client/

因此,我首先登錄並創建一個信封(其信封定義的狀態為:“已創建”而不是“已發送”),然后嘗試運行“ updateDocuments”,如下所示:

    // create a new envelope object that we will manage the signature request through
    var envDef = new docusign.EnvelopeDefinition();
    var docDef = new docusign.Document();

    docDef = [
      {
        documentId: 1,
        name: "CONTRACT",
        fileExtension: "jpg",
        documentBase64: base64_encode("./someimage.jpg")
      }
    ];
    envDef.documents = docDef;


    envelopesApi.updateDocuments(accountId, envelopeId,
      {"envelopeDefinition": envDef}
    ,function(error, data, response) {
        console.log(JSON.stringify(response,1,2));
        process.exit();
    });

控制台日志顯示以下錯誤(FORMAT_CONVERSION_ERROR):

{
  "req": {
    "method": "PUT",
    "url": "https://demo.docusign.net/restapi/v2/accounts/2984497/envelopes/ef87c144-497a-4ce8-8d81-cd1068f90daf/documents",
    "data": {
      "documents": [
        {
          "documentId": 1,
          "name": "contract",
          "fileExtension": "jpg",
          "documentBase64": "***HUGE base64 string***"
        }
      ]
    }
  },
  "header": {
    "cache-control": "no-cache",
    "content-length": "291",
    "content-type": "application/json; charset=utf-8",
    "x-ratelimit-reset": "1496912400",
    "x-ratelimit-limit": "1000",
    "x-ratelimit-remaining": "995",
    "x-docusign-tracetoken": "b44c0be9-96f3-4348-8e01-04babd762691",
    "date": "Thu, 08 Jun 2017 08:15:46 GMT",
    "connection": "close",
    "strict-transport-security": "max-age=31536000; includeSubDomains"
  },
  "status": 200,
  "text": "{\r\n  \"envelopeId\": \"ef87c144-497a-4ce8-8d81-cd1068f90daf\",\r\n  \"envelopeDocuments\": [\r\n    {\r\n      \"documentId\": \"1\",\r\n      \"order\": \"8\",\r\n      \"errorDetails\": {\r\n        \"errorCode\": \"FORMAT_CONVERSION_ERROR\",\r\n        \"message\": \"The data could not be converted.\"\r\n      }\r\n    }\r\n  ]\r\n}"
}

根據一個答案,我用谷歌搜索了我的內容編碼標頭是不正確的..但我不認為這是因為json-documentBase64會被讀出,而不是多部分的塊

知道我在做什么錯嗎?

謝謝,尼爾斯

Nico和Niels,

  1. 我總是建議配置DocuSign https://support.docusign.com/articles/API-Request-Logging中提供的調試日志記錄
  2. 我始終建議使用Postman或SoapUI(開源和免費的,都可以在Windows和Mac上運行,然后從看到的日志中設置調用。可幫助您了解在API中最有效的方法,然后針對您的平台調整API SDK代碼|語言(本例中為nodejs)以正確准備要發送的內容。

  3. 通常,您打算做的事是正確的,但是,除非您提供實際的“ DS收到的內容”,否則很難調試一段代碼。 :-)

  4. 我更喜歡使用復合模板模型和多部分表單提交方式來處理“復雜而異國情調”的信封,並且誠實地避免使用對象模型,這是因為增加和減少僅添加文檔,收件人等的成本。但是,我發現它可以提高速度,性能和可測試性。

  5. 我還注意到,未通過Aspose或其他實用程序將Jpg和圖像轉換為PDF可能會導致DocuSign“第三方轉換器(基於供應商)”出現問題,因此再次進行測試時,最好將其作為pdf並在base64版本中使用第一。

希望對您有所幫助,請告訴我們您的決定,如果您添加DS收到的剪報,我們中的一些人可能會提供更多見解。 最終的問題是在3:00 am時幫助其他需要做出里程碑的開發人員總是很高興。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM