DocuSign Rest API 使用复合模板发送信封
DocuSign Rest API send envelope using composite template
我有一个用于发送以下内容的复合模板:
- 1 份文件供签署
- 另一个不需要签名但包含在内的文档
- 存储在模板中的文档
我收到此错误:执行网络请求时出错。 {
"errorCode": "UNSPECIFIED_ERROR",
"message": "Invalid length for a Base-64 char array or string." 我已验证 Base64 是 4 的倍数。我认为问题是我没有正确的内容类型。我正在使用 Nintex 和 SharePoint 将其余 API 发送到 DocuSign。
内容类型:multipart/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"
Link 到 base64-
http://www.mihomes.com/corp/vit/Base64.txt
在查看您发布的请求时,我突然想到了一些事情:
首先,您错误地将 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)多次指定文档字节——一次作为 document 对象的一部分(使用documentbase64 属性)在每个复合模板中,并再次在多部分请求的附加部分中。我建议从每个复合模板对象的 document 对象中删除 documentbase64 属性——如果您指定文档字节,则不需要在多部分消息的其他部分。
接下来,如果 CCare_Pledge.pdf 是您正在使用的模板中包含的第一个文档,那么您应该删除 document 来自该复合模板对象的属性(对象):
"document": {
"documentId": 4,
"name": "CCare_Pledge.pdf"
}
并删除请求的最后部分:
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"
这不是必需的,因为文档来自模板本身,所以您不需要在请求中指定文档信息。
最后,确保您的请求以正确的边界终止符字符串结尾:
--MY_BOUNDARY--
(这个 other post 的答案显示了关于边界分隔符的整体请求结构的一个很好的例子。)
实施这些建议的更改后,您的请求结构应如下所示:
--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--
我有一个用于发送以下内容的复合模板:
- 1 份文件供签署
- 另一个不需要签名但包含在内的文档
- 存储在模板中的文档
我收到此错误:执行网络请求时出错。 { "errorCode": "UNSPECIFIED_ERROR", "message": "Invalid length for a Base-64 char array or string." 我已验证 Base64 是 4 的倍数。我认为问题是我没有正确的内容类型。我正在使用 Nintex 和 SharePoint 将其余 API 发送到 DocuSign。
内容类型:multipart/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"
Link 到 base64- http://www.mihomes.com/corp/vit/Base64.txt
在查看您发布的请求时,我突然想到了一些事情:
首先,您错误地将 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)多次指定文档字节——一次作为 document 对象的一部分(使用documentbase64 属性)在每个复合模板中,并再次在多部分请求的附加部分中。我建议从每个复合模板对象的 document 对象中删除 documentbase64 属性——如果您指定文档字节,则不需要在多部分消息的其他部分。
接下来,如果 CCare_Pledge.pdf 是您正在使用的模板中包含的第一个文档,那么您应该删除 document 来自该复合模板对象的属性(对象):
"document": {
"documentId": 4,
"name": "CCare_Pledge.pdf"
}
并删除请求的最后部分:
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"
这不是必需的,因为文档来自模板本身,所以您不需要在请求中指定文档信息。
最后,确保您的请求以正确的边界终止符字符串结尾:
--MY_BOUNDARY--
(这个 other post 的答案显示了关于边界分隔符的整体请求结构的一个很好的例子。)
实施这些建议的更改后,您的请求结构应如下所示:
--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--