docusignapi - DocuSign - 从 Java SDK listStatusChanges() 获取签名文档正文
问题描述
我必须使用 EnvelopeAPI.listStatusChanges() 来轮询签名的信封。它提供了一个对象EnvelopeInfo,包含一个List。对于每个信封,我想检索已签名文档的正文,但 Envelope.getEnvelopeDocuments() 只返回 null。
ListStatusChangesOptions opt = api.new ListStatusChangesOptions();
opt.setFromDate(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(lastPoll.minusDays(1)));
EnvelopesInformation info = api.listStatusChanges(authService.getAccountId(),opt);
List<Envelope> envList = info.getEnvelopes();
assert (envList != null);
for (Envelope env : envList) {
String envId = env.getEnvelopeId());
String status = env.getStatus();
LocalDateTime changeTime = LocalDateTime.from(
DateTimeFormatter.ISO_DATE_TIME
.parse(env.getStatusChangedDateTime()));
System.out.format("%s: Changed status of \"%s\" in %s\n",
changeTime.toString(), envId(),status());
if (status.equals("completed")) {
List<EnvelopeDocument> documents = env.getEnvelopeDocuments();
assert(documents != null);
}
}
在示例中,文档上的最后一个断言总是失败。我究竟做错了什么?
我得到的唯一相关日志是:
TraceToken: de41cfce-8a4d-4ef4-9a5f-a47659fa16fd
Timestamp: 2021-11-09T10:17:19.5448174Z
GET https://demo.docusign.net:7801/restapi/v2.1/accounts/<xxx>/envelopes?from_date=2021-11-08T11%3A14%3A13.8906278
Content-Length: 0
Connection: keep-alive
Accept: application/json
Authorization: Bearer [omitted]
Host: demo.docusign.net
User-Agent: Swagger-Codegen/3.15.0/java
X-DocuSign-SDK: Java
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
x-forwarded-for: 93.34.235.164
200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 9671
X-DocuSign-TraceToken: de41cfce-8a4d-4ef4-9a5f-a47659fa16fd
{
"resultSetSize": "6",
"startPosition": "0",
"endPosition": "5",
"totalSetSize": "6",
"nextUri": "",
"previousUri": "",
"envelopes": [
{
"status": "completed",
"documentsUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/documents",
"recipientsUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/recipients",
"attachmentsUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/attachments",
"envelopeUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2",
"emailSubject": "Documents to sign",
"envelopeId": "fe3b2d69-1671-49cb-9af9-4186f0777ae2",
"signingLocation": "online",
"customFieldsUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/custom_fields",
"notificationUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-08T11:28:58.4730000Z",
"lastModifiedDateTime": "2021-11-08T11:28:58.4730000Z",
"deliveredDateTime": "2021-11-08T11:29:17.5000000Z",
"sentDateTime": "2021-11-08T11:28:59.0500000Z",
"completedDateTime": "2021-11-08T11:29:54.1470000Z",
"statusChangedDateTime": "2021-11-08T11:29:54.1470000Z",
"documentsCombinedUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/documents/combined",
"certificateUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/documents/certificate",
"templatesUri": "/envelopes/fe3b2d69-1671-49cb-9af9-4186f0777ae2/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Michele Bert",
"userId": "xxx",
"accountId": "xxx",
"email": "michele.bert@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
},
{
"status": "sent",
"documentsUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/documents",
"recipientsUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/recipients",
"attachmentsUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/attachments",
"envelopeUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb",
"emailSubject": "Sottoscrizione Mario Rossi",
"emailBlurb": "Buongiorno,\ncome da accordi sono a inviarti la proposta di investimento da sottoscrivere.\nTi ricordo che la proposta ha una validità di 48 ore dalla data di consegna.\n\nCordiali saluti\n",
"envelopeId": "fb263fbd-6842-48fa-9665-03df9af2accb",
"signingLocation": "online",
"customFieldsUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/custom_fields",
"notificationUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-09T07:15:48.6970000Z",
"lastModifiedDateTime": "2021-11-09T07:17:00.6830000Z",
"sentDateTime": "2021-11-09T07:17:01.4670000Z",
"statusChangedDateTime": "2021-11-09T07:17:01.4670000Z",
"documentsCombinedUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/documents/combined",
"certificateUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/documents/certificate",
"templatesUri": "/envelopes/fb263fbd-6842-48fa-9665-03df9af2accb/templates",
"expireEnabled": "true",
"expireAfter": "2",
"sender": {
"userName": "Andrea Debortoli",
"userId": "xxx",
"accountId": "xxx",
"email": "andrea.debortoli@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "true",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
},
{
"status": "completed",
"documentsUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/documents",
"recipientsUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/recipients",
"attachmentsUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/attachments",
"envelopeUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7",
"emailSubject": "Documents to sign",
"envelopeId": "3d7130d7-b5bb-4579-9c25-f525c22064e7",
"signingLocation": "online",
"customFieldsUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/custom_fields",
"notificationUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-09T09:28:23.3930000Z",
"lastModifiedDateTime": "2021-11-09T09:28:23.3930000Z",
"deliveredDateTime": "2021-11-09T09:28:43.6400000Z",
"sentDateTime": "2021-11-09T09:28:23.9730000Z",
"completedDateTime": "2021-11-09T09:29:24.9800000Z",
"statusChangedDateTime": "2021-11-09T09:29:24.9800000Z",
"documentsCombinedUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/documents/combined",
"certificateUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/documents/certificate",
"templatesUri": "/envelopes/3d7130d7-b5bb-4579-9c25-f525c22064e7/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Michele Bert",
"userId": "xxx",
"accountId": "xxx",
"email": "michele.bert@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
},
{
"status": "completed",
"documentsUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/documents",
"recipientsUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/recipients",
"attachmentsUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/attachments",
"envelopeUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a",
"emailSubject": "Documents to sign",
"envelopeId": "99f3a387-f8e8-4763-9b50-3c2e49fc536a",
"signingLocation": "online",
"customFieldsUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/custom_fields",
"notificationUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-09T09:45:09.1130000Z",
"lastModifiedDateTime": "2021-11-09T09:45:09.1130000Z",
"deliveredDateTime": "2021-11-09T09:45:26.5430000Z",
"sentDateTime": "2021-11-09T09:45:10.0370000Z",
"completedDateTime": "2021-11-09T09:45:53.7670000Z",
"statusChangedDateTime": "2021-11-09T09:45:53.7670000Z",
"documentsCombinedUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/documents/combined",
"certificateUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/documents/certificate",
"templatesUri": "/envelopes/99f3a387-f8e8-4763-9b50-3c2e49fc536a/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Michele Bert",
"userId": "xxx",
"accountId": "xxx",
"email": "michele.bert@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
},
{
"status": "completed",
"documentsUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/documents",
"recipientsUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/recipients",
"attachmentsUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/attachments",
"envelopeUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4",
"emailSubject": "Documents to sign",
"envelopeId": "864d7b45-e5a2-4188-a5c3-52693a2909c4",
"signingLocation": "online",
"customFieldsUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/custom_fields",
"notificationUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-09T09:58:49.7900000Z",
"lastModifiedDateTime": "2021-11-09T09:58:49.7900000Z",
"deliveredDateTime": "2021-11-09T09:59:06.0800000Z",
"sentDateTime": "2021-11-09T09:58:50.4330000Z",
"completedDateTime": "2021-11-09T09:59:37.2700000Z",
"statusChangedDateTime": "2021-11-09T09:59:37.2700000Z",
"documentsCombinedUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/documents/combined",
"certificateUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/documents/certificate",
"templatesUri": "/envelopes/864d7b45-e5a2-4188-a5c3-52693a2909c4/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Michele Bert",
"userId": "xxx",
"accountId": "xxx",
"email": "michele.bert@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
},
{
"status": "completed",
"documentsUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/documents",
"recipientsUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/recipients",
"attachmentsUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/attachments",
"envelopeUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce",
"emailSubject": "Documents to sign",
"envelopeId": "f01ef821-b29c-4747-804d-b379644b9bce",
"signingLocation": "online",
"customFieldsUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/custom_fields",
"notificationUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/notification",
"allowMarkup": "false",
"createdDateTime": "2021-11-09T10:14:16.2630000Z",
"lastModifiedDateTime": "2021-11-09T10:14:16.2800000Z",
"deliveredDateTime": "2021-11-09T10:14:36.8400000Z",
"sentDateTime": "2021-11-09T10:14:17.5300000Z",
"completedDateTime": "2021-11-09T10:15:11.1630000Z",
"statusChangedDateTime": "2021-11-09T10:15:11.1630000Z",
"documentsCombinedUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/documents/combined",
"certificateUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/documents/certificate",
"templatesUri": "/envelopes/f01ef821-b29c-4747-804d-b379644b9bce/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Michele Bert",
"userId": "xxx",
"accountId": "xxx",
"email": "michele.bert@xxx.it"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
}
]
}
对 Envelope.getEnvelopeDocuments() 的调用似乎没有在任何 REST 调用中结束。我希望它在 Envelope.documentsUri 字段中包含的 URI 处请求文档列表。我错了吗?
解决方案
为了检索文档信息,请求属性include必须包含“文档”,如 [1] 中所述。从java SDK来看,它对应于调用
listStatusChangesOptions.setInclude("documents,...");
...说明您需要检索的任何其他详细信息类型的位置(例如,在我的情况下,我还需要收件人列表,因此我设置了“收件人,文档”)。
然后,在请求返回的 Envelope 对象上,可以调用 getEnvelopeDocuments() 方法,该方法返回Document对象的列表。此类对象包含所有摘要信息,包括“documentUri”,格式如下:
/envelopes/c34c029d-1074-4h66-afe1-324b851397c4/documents/1
它与基本路径连接,形成了用于下载文档的 REST API 的 URL。换句话说,使用这个 URI 或EnvelopesApi.getDocument()是完全相同的东西。
结论是,如果不从每小时可用的电话中减少至少一个呼叫,就无法下载文档
[1] https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/liststatuschanges/
推荐阅读
- batch-file - 从批处理中读取字符分隔的属性文件
- visual-studio-code - How can I specify which components of an extension to use
- c# - Filename is getting from a Fileuploader
- android - Android : [Adding Custom framework.jar file] duplicate entry for ConnectTimeoutException
- arcore - Where can I find support for making ARCore compatible Hardware?
- html - Bootstrap - button style not being applied to buttons
- php - 顺序重复数组的索引,直到它与指定的值匹配
- docker - 连接错误:获取服务器 API 版本时出错:Ansible
- arrays - Powershell脚本将列表分解为多个数组
- php - 使用 PHP 或 Bash 查找当前用户的公共 SSH 密钥是否被授权用于远程主机上的 SSH