2016-07-23 87 views
0

我有我用來發送以下合成模板發送信封:的DocuSign REST API使用複合模板

  1. 1號文件簽署
  2. 並不需要簽署另一份文件,但包括
  3. 保存在模板中的文檔

我收到此錯誤:執行Web請求時出錯。 { 「errorCode」:「Addresses_ERROR」, 「message」:「Base-64字符數組或字符串的無效長度。」我已經證實Base64是4的倍數。我認爲問題是我沒有正確的內容類型。我正在使用Nintex和SharePoint將Rest API發送給DocuSign。

內容類型:多重/ form-data的;邊界= MY_BOUNDARY

Accept: application/json 
Host: na2.docusign.net 


--MY_BOUNDARY 
Content-Type: application/json 
Content-Disposition: form-data 

{ 
"emailSubject": "Contract Package for {ItemProperty:Title}", 
"status" : "sent", 
"compositeTemplates": [ 
{ 
"inlineTemplates": [ 
    { 
     "sequence" : 2, 
     "recipients": { 
      "signers" : [ 
      { 
       "email": "{WorkflowVariable:varCreatedByEmail}", 
       "name": "{WorkflowVariable:varCreatedByName}", 
       "recipientId": "1", 
       "roleName": "MI Employee", 
       "routingOrder": "1", 
       "tabs": 
        {"signerAttachmentTabs": [ 
         {"anchorString": "/ea1/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Scope of Work Attachment", 
          "optional": "true", 
          "tabOrder": 1}, 
         {"anchorString": "/ea2/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Pricing Attachment", 
          "optional": "true", 
          "tabOrder": 3}], 
        "textTabs":[ 
         {"anchorString": "/ec1/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Scope of Work Text", 
          "disableAutoSize": true, 
          "width": 550, 
          "height": 220, 
          "tabOrder": 2}, 
         {"anchorString": "/ec2/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Pricing Text", 
          "disableAutoSize": true, 
          "width": 550, 
          "height": 220, 
          "tabOrder": 4}] 
        } 
      }, 
      { 
       "email": "{ItemProperty:E_x002d_Mail}", 
       "name": "{ItemProperty:Primary_x0020_Contact}", 
       "recipientId": "2", 
       "roleName": "Vendor", 
       "routingOrder": "2", 
       "tabs": 
        {"fullNameTabs": [ 
         {"anchorString": "/vn/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "signHereTabs":[ 
         {"anchorString": "/vs/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "dateSignedTabs":[ 
         {"anchorString": "/dvs/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "initialHereTabs":[ 
         {"anchorString": "/vi/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "titleTabs":[ 
         {"anchorString": "/vt/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "emailAddressTabs":[ 
         {"anchorString": "/ve/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "textTabs":[ 
         {"anchorString": "/va1/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Address Line 1"}, 
         {"anchorString": "/va2/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Address Line 2", 
          "required": false}, 
         {"anchorString": "/va3/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Address Line 3",}, 
         {"anchorString": "/vc/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0", 
          "tabLabel": "Vendor Name", 
          "disableAutoSize": true, 
          "width": 225, 
          "height": 32}] 
        } 
      }, 
      { 
       "email": "{WorkflowVariable:varContractApproverEmail}", 
       "name": "{WorkflowVariable:varContractApproverName}", 
       "recipientId": "3", 
       "roleName": "MI Approver", 
       "routingOrder": "3", 
       "tabs": 
        {"signHereTabs":[ 
         {"anchorString": "/as/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "dateSignedTabs":[ 
         {"anchorString": "/das/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "fullNameTabs":[ 
         {"anchorString": "/an/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "titleTabs":[ 
         {"anchorString": "/at/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
       , 
        "emailAddressTabs":[ 
         {"anchorString": "/ae/", 
          "anchorXOffset": "1", 
          "anchorYOffset": "0"}] 
        } 
      }   ] 
        } 
    }    ], 
    "document": { 
     "documentId": 1, 
     "name": "{WorkflowVariable:varContractName}", 
     "documentbase64": "{WorkflowVariable:varContractBase64}" 
    } 
}, 
{ 
"inlineTemplates": [ 
    { 
     "sequence" : 3, 
     "recipients": { 
      "carbonCopies" : [ 
      { 
       "email": "{WorkflowVariable:varCreatedByEmail}", 
       "name": "{Common:InitiatorsDisplayName}", 
       "recipientId": "1", 
       "roleName": "MI Employee", 
       "routingOrder": "1" 
      }, 
      { 
       "email": "{ItemProperty:E_x002d_Mail}", 
       "name": "{ItemProperty:Primary_x0020_Contact}", 
       "recipientId": "2", 
       "roleName": "Vendor", 
       "routingOrder": "2" 
      }, 
      { 
       "email": "{WorkflowVariable:varContractApproverEmail}", 
       "name": "{WorkflowVariable:varContractApproverName}", 
       "recipientId": "3", 
       "roleName": "MI Approver", 
       "routingOrder": "3" 
      }] 
     } 
    }], 
    "document": { 
     "documentId": 2, 
     "name": "{WorkflowVariable:varExhibitAName}", 
     "documentbase64": "{WorkflowVariable:varExhibitABase64}" 
    } 
}, 
{ 
    "serverTemplates": [ 
    { 
     "sequence" : 6, 
     "templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83" 
    }], 
    "inlineTemplates": [ 
    { 
     "sequence" : 7, 
     "recipients": { 
      "signers" : [{ 
       "email": "{WorkflowVariable:varCreatedByEmail}", 
       "name": "{Common:InitiatorsDisplayName}", 
       "recipientId": "1", 
       "roleName": "MI Employee", 
       "routingOrder": "1" 
      }, 
      { 
       "email": "{ItemProperty:E_x002d_Mail}", 
       "name": "{ItemProperty:Primary_x0020_Contact}", 
       "recipientId": "2", 
       "roleName": "Vendor", 
       "routingOrder": "2", 
       "tabs": { 
       "textTabs": [ 
       { 
       "tabLabel": "VendorName"}]} 
      }, 
      { 
       "email": "{WorkflowVariable:varContractApproverEmail}", 
       "name": "{WorkflowVariable:varContractApproverName}", 
       "recipientId": "3", 
       "roleName": "MI Approver", 
       "routingOrder": "3" 
      } 
      ] 
     } 
    }], 
    "document": { 
     "documentId": 4, 
     "name": "CCare_Pledge.pdf" 
    } 
}] 
} 

--MY_BOUNDARY 
Content-Type: application/pdf 
Content-Disposition: file; filename="{WorkflowVariable:varContractName}";  documentid="1" 

<document bytes removed> 

--MY_BOUNDARY-- 
Content-Type: application/pdf 
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}";  documentid="2" 

<document bytes removed> 

--MY_BOUNDARY-- 
Content-Type: application/pdf 
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4" 

鏈接base64- http://www.mihomes.com/corp/vit/Base64.txt

+0

你引用的錯誤消息退出e清楚了,但是你已經刪除了消息的基本64部分,所以我們看不到它是否合理。 – AdrianHHH

+0

因此,如果認爲錯誤是由此API調用的documentbase64部分引發的,請確保提供的b64編碼字符串是一個連續的行。不應該包含任何換行符。 –

+0

我嘗試刪除換行符,但仍然收到相同的錯誤。 – KishRandle

回答

0

在查看請求您已發佈的幾件事情跳到我身邊:

首先,您錯誤地指定了零件的邊界分隔符,該零件指定了documentid = 2爲「--MY_BOUNDARY--

--MY_BOUNDARY-- 
Content-Type: application/pdf 
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}";  documentid="2" 

通過包括-在這個邊界字符串的結尾,你指示多消息的結束,所以它的很可能DocuSign不讀取該字符串後面的任何請求內容。我建議改變這個以「--MY_BOUNDARY」

其次,你指定兩個文件的文件字節多次(documentid = 1和documentid = 2) - 曾經作爲的一部分文檔對象(使用documentbase64屬性)在每個複合模板中,並再次在多部分請求的其他部分。我建議從每個Composite Template對象的文檔對象中刪除documentbase64屬性 - 如果要在多部分消息的其他部分中指定文檔字節,則不需要該屬性。

接下來,如果CCare_Pledge.pdf是包含在你使用模板的頭文件,那麼你應該刪除從複合模板對象文件屬性(對象):

"document": { 
    "documentId": 4, 
    "name": "CCare_Pledge.pdf" 
} 

並刪除請求的最後部分:

--MY_BOUNDARY-- 
Content-Type: application/pdf 
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4" 

這不是必須的,因爲文檔來自模板本身,因此您無需指定d請求中的ocument信息。

最後,請確保您的請求與正確的邊界終止字符串結尾:(這個問題的答案other post顯示總體要求結構的關於邊界分隔一個很好的例子)

--MY_BOUNDARY-- 

一旦你實現這些建議的更改,您的請求結構應該是這樣的:

--MY_BOUNDARY 
Content-Type: application/json 
Content-Disposition: form-data 

{ 
    "emailSubject": "Contract Package for {ItemProperty:Title}", 
    "status" : "sent", 
    "compositeTemplates": [ 
     { 
      "inlineTemplates": [ 
       { 
        "sequence" : 2, 
        "recipients": { 
         ... 
        } 
       } 
      ], 
      "document": { 
       "documentId": 1, 
       "name": "{WorkflowVariable:varContractName}" 
      } 
     }, 
     { 
      "inlineTemplates": [ 
       { 
        "sequence" : 3, 
        "recipients": { 
         ... 
        } 
       } 
      ], 
      "document": { 
       "documentId": 2, 
       "name": "{WorkflowVariable:varExhibitAName}" 
      } 
     }, 
     { 
      "serverTemplates": [ 
       { 
        "sequence" : 6, 
        "templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83" 
       } 
      ], 
      "inlineTemplates": [ 
       { 
        "sequence" : 7, 
        "recipients": { 
         ... 
        } 
       } 
      ] 
     } 
    ] 
} 

--MY_BOUNDARY 
Content-Type: application/pdf 
Content-Disposition: file; filename="{WorkflowVariable:varContractName}"; documentid="1" 

<document bytes removed> 

--MY_BOUNDARY 
Content-Type: application/pdf 
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}"; documentid="2" 

<document bytes removed> 

--MY_BOUNDARY-- 
相關問題