Reputation: 33
I must use EnvelopeAPI.listStatusChanges() to poll signed envelopes. It provides an object EnvelopeInfo, containig a List. For each Envelupe I would like to retrive the signed documents' body, but the Envelope.getEnvelopeDocuments() just return 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);
}
}
In the example, the last assert on documents always fails. What am I doing wrong?
The only relevat log I got is:
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": "[email protected]"
},
"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": "[email protected]"
},
"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": "[email protected]"
},
"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": "[email protected]"
},
"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": "[email protected]"
},
"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": "[email protected]"
},
"purgeState": "unpurged",
"envelopeIdStamping": "false",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
}
]
}
The call to Envelope.getEnvelopeDocuments() does not seem to end up in any REST calls. I expected it to request the document list at the URI contained in Envelope.documentsUri field. Am I wrong?
Upvotes: 0
Views: 320
Reputation: 33
In order for the documents info to be retrieved, the request property include must contain "documents", as stated at [1]. From the java SDK point of view, it correspond to call
listStatusChangesOptions.setInclude("documents,...");
Where the ... states for any other detail type you need to retrieve (in my case, for example, I need also the list of recipients, so I set "recipients, documents").
Then, on Envelope objects returned by the request, the getEnvelopeDocuments() method can be called, which return a list of Document objects. Such objects contain all the summary information, included the "documentUri", in a form like:
/envelopes/c34c029d-1074-4h66-afe1-324b851397c4/documents/1
which, concatenated to the basepath, forms exactly the URL of the REST API to download a document. In other words, using this URI or the EnvelopesApi.getDocument() are exactly the same things.
The conclusion is that there are no way to download documents, without down-counting at least one call from the per-hour available
[1] https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/liststatuschanges/
Upvotes: 1
Reputation: 49104
It is not clear to me what env.getEnvelopeDocuments()
is doing.
You should be using the EnvelopeDocuments:get API method.
Here is a code example of calling the API method from Java.
byte[] results = envelopesApi.getDocument(accountId, envelopeId, documentId);
To get all the documents combined into one document, use the reserved value "combined"
as the documentId.
Upvotes: 0