您好我正在尝试使用COMPOSITE模板来制作一个模板并在创建信封时添加文档。
完整的请求如下。
但是我得到" UNSPECIFIED_ERROR"如下
我是新手使用docusign和复合模板API。
如果有人在参考有关复合模板的在线资料后尝试了请求,可能会指出错误。
感谢阅读!!!
响应:
{
errorCode: "UNSPECIFIED_ERROR"
message: "An item with the same key has already been added."
}
REQUEST
POST https://demo.docusign.net/restapi/v2/accounts/ACTID/envelopes HTTP/1.1
Host: demo.docusign.net
Connection: keep-alive
Content-Length: 6640
X-DocuSign-Authentication: <DocuSignCredentials><Username>username.com</Username><Password>PA$$W0RD</Password><IntegratorKey>INTG KEY</IntegratorKey></DocuSignCredentials>
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"accountId": "act_ID",
"brandId": "brnd_ID",
"status": "SENT",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": 1,
"templateId": "temp_ID_1"
}
],
"inlineTemplates": [
{
"sequence": 1,
"recipients": {
"signers": [
{
"name": "Signer Name",
"email": "signer@email.com",
"recipientId": "1",
"roleName": "signer",
"tabs": {
"textTabs": [
{
"tabLabel": "SignerRole",
"value": "signerRole"
},
{
"tabLabel": "SignerAddress",
"value": "test TT DEMO"
},
{
"tabLabel": "date",
"value": "05/10/2014"
}
]
}
}
],
"carbonCopies": [
{
"name": "CarbonCopyName",
"email": "carboncopy@emailcom",
"recipientId": "1",
"roleName": "carbonCopyRole"
}
]
}
}
]
},
{
"inlineTemplates": [
{
"sequence": 2,
"document": {
"name": "body.pdf"
}
}
]
}
]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="body.pdf"
%PDF-1.4
%????
2 0 obj
<<
--MY_BOUNDARY--
答案 0 :(得分:2)
请求中的每个 compositeTemplate 对象都必须同时指定:
和
例如,以下多部分请求将创建一个包含服务器模板中的文档的信封,后跟请求中指定的其他文档:
POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"username@test.com","Password":"mypassword","IntegratorKey":"ABCD-dbd5f342-d9f6-47c3-b293-xxxxxxxxxxxx"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 272956
Expect: 100-continue
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"status" : "sent",
"emailSubject" : "Test Envelope Subject",
"emailBlurb" : "Test Envelope Blurb",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "TEMPLATE_ID"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "abbysemail@outlook.com",
"name": "Abby Abbott",
"recipientId": "1",
"roleName": "Initiator",
"routingOrder":"1"
}
]
}
}]
},
{
"inlineTemplates": [
{
"sequence" : 1,
"recipients": {
"signers" : [{
"email": "abbysemail@outlook.com",
"name": "Abby Abbott",
"recipientId": "1"
}]
}
}],
"document": {
"documentId": 1,
"name": "Customer Agreement",
"fileExtension": "pdf"
}
}
]}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"
PDF_BYTE_STREAM_HERE
--MY_BOUNDARY--
如果我希望附加文档首先出现在信封中,我只需在请求中交换 compositeTemplate 对象的顺序,以便在服务器模板之前指定文档:
POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"username@test.com","Password":"mypassword","IntegratorKey":"ABCD-dbd5f342-d9f6-47c3-b293-xxxxxxxxxxxx"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 272956
Expect: 100-continue
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"status" : "sent",
"emailSubject" : "Test Envelope Subject",
"emailBlurb" : "Test Envelope Blurb",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence" : 1,
"recipients": {
"signers" : [{
"email": "abbysemail@outlook.com",
"name": "Abby Abbott",
"recipientId": "1"
}]
}
}],
"document": {
"documentId": 1,
"name": "Customer Agreement",
"fileExtension": "pdf"
}
},
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "TEMPLATE_ID"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "abbysemail@outlook.com",
"name": "Abby Abbott",
"recipientId": "1",
"roleName": "Initiator",
"routingOrder":"1"
}
]
}
}]
}
]}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"
PDF_BYTE_STREAM_HERE
--MY_BOUNDARY--
根据您在问题中发布的代码,我怀疑错误是由请求中的第二个 compositeTemplate 对象未指定收件人这一事实引起的。
最后,还有一些评论:
答案 1 :(得分:1)
我想知道这是否与您提供的内联文档有关。我看到您指定了文档名称,但没有documentId
,这可能导致错误,因为它可能默认为documentId
= 1
,这很可能是服务器模板文档使用的。
尝试这样的事情:
"document": {
"name": "body.pdf",
"documentId": "2"
}