我嘗試通過DocuSign Rest API(Java)創建基於模板的信封時出現以下錯誤。獲取錯誤消息作爲不存在的特定文檔ID。我曾經上傳文檔ID爲「1」的文檔,但是對於一個模板,我得到的錯誤不是這樣。DocuSign Rest API - TAB_REFERS_TO_MISSING_DOCUMENT
Exception: com.docusign.esign.client.ApiException: {
"errorCode": "TAB_REFERS_TO_MISSING_DOCUMENT",
"message": "The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 69681238 which is not present."
}
任何人都可以解釋爲上述情況?我是否需要在模板或代碼中進行更改?任何額外的參數,我必須通過?
信封創建代碼:
try {
Path path = Paths.get(file);
fileBytes = Files.readAllBytes(path);
} catch (IOException ioExcp) {
System.out.println("Exception: " + ioExcp);
return null;
}
// add a document to the envelope
Document doc = new Document();
String base64Doc = Base64.encodeBase64String(fileBytes);
doc.setDocumentBase64(base64Doc);
doc.setName(fileName);
doc.setDocumentId("1");
List<Document> docs = new ArrayList<Document>();
docs.add(doc);
envDef.setTemplateId(templateId());
envDef.setDocuments(docs);
List<TemplateRole> templateRolesList = new LinkedList<TemplateRole>();
TemplateRole templateRole = new TemplateRole();
templateRole.setEmail(signerEmail);
templateRole.setName(signerName);
templateRole.setRoleName("Signer1");
templateRole.setRoutingOrder("1");
templateRolesList.add(templateRole);
TemplateRole templateRole2 = new TemplateRole();
templateRole2.setName(signerName1);
templateRole2.setRoleName("Signer2");
templateRole2.setRoutingOrder("2");
templateRole2.setEmail(signerEmail1);
templateRolesList.add(templateRole2);
envDef.setTemplateRoles(templateRolesList);
envDef.setAllowRecipientRecursion("true");
envDef.setStatus("created");
try {
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId(), envDef);
DocumentTemplateList documentTemplateList = new DocumentTemplateList();
DocumentTemplate documentTemplate = new DocumentTemplate();
documentTemplate.setTemplateId(templateId());
documentTemplate.setDocumentId(doc.getDocumentId());
documentTemplateList.getDocumentTemplates().add(documentTemplate);
envelopesApi.applyTemplateToDocument(accountId,
envelopId(), doc.getDocumentId(),
documentTemplateList);
} catch (com.docusign.esign.client.ApiException ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
}
正如你提到的,從模板列表獲得文檔ID。我將文檔數組視爲空。這是迴應。
class EnvelopeTemplateResult {
templateId: <templateId>
name: Template 1
shared: true
password:
description:
lastModified: 2017-06-06T19:45:35.7670000Z
pageCount: 15
uri: /templates/<uri>
folderName: Templates
folderId: <folderId>
folderUri: /folders/<folderUri>
parentFolderUri: null
owner: class UserInfo {
userName: User Name
email: [email protected]
userId: userID
userType: null
userStatus: null
uri: null
errorDetails: null
}
documents: []
recipients: null
transactionId: null
status: null
documentsUri: null
recipientsUri: null
asynchronous: null
envelopeUri: null
emailSubject: Sign Document
emailBlurb: Please sign this document
envelopeId: null
signingLocation: Online
customFieldsUri: null
envelopeIdStamping: null
authoritativeCopy: false
notification: null
notificationUri: null
enforceSignerVisibility: false
enableWetSign: true
allowMarkup: false
allowReassign: false
createdDateTime: null
lastModifiedDateTime: null
deliveredDateTime: null
sentDateTime: null
completedDateTime: null
voidedDateTime: null
voidedReason: null
deletedDateTime: null
declinedDateTime: null
statusChangedDateTime: null
documentsCombinedUri: null
certificateUri: null
templatesUri: null
messageLock: null
recipientsLock: null
brandLock: null
brandId: null
useDisclosure: null
emailSettings: null
purgeState: null
lockInformation: null
is21CFRPart11: null
isUniversalSignatureEnvelope: null
}
請分享您的信封創建代碼和文檔的ID。您可以使用[listTemplateDocuments](https://docs.docusign.com/esign/restapi/Templates/TemplateDocuments/list/)api來檢索模板上的文檔ID。另請參閱此[答案](https://stackoverflow.com/a/36614213/1219543) –