Rust
Rust
DocuSign List Envelope Documents
See more DocuSign Examples
Retrieve a list of all documents within a specific envelope.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// Implements the following HTTP request:
// GET /restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents
// Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
let json_token = chilkat::JsonObject::new();
// Load a previously obtained OAuth2 access token.
if json_token.load_file("qa_data/tokens/docusign.json").is_err() {
println!("{}", json_token.last_error_text());
return;
}
http.set_auth_token(&json_token.string_of("access_token").unwrap_or_default());
// Use your account ID and a valid envelopeId here:
let _ = http.set_url_var("accountId", "7f3f65ed-5e87-418d-94c1-92499ddc8252");
let _ = http.set_url_var("envelopeId", "90d7e40a-b4bd-4ccd-bf38-c80e37954a13");
let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/documents", &sb_response_body).is_err() {
println!("{}", http.last_error_text());
return;
}
let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);
println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());
let resp_status_code = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
println!("Response Header:");
println!("{}", http.last_header());
println!("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "envelopeId": "90d7e40a-b4bd-4ccd-bf38-c80e37954a13",
// "envelopeDocuments": [
// {
// "documentId": "1",
// "documentIdGuid": "ca1d3cc6-9bc3-48d6-a5d8-a85d9acdcde1",
// "name": "helloWorld.pdf",
// "type": "content",
// "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/1",
// "order": "1",
// "pages": [
// {
// "pageId": "fbf93a36-6b60-484d-94bd-ee3c08c0a546",
// "sequence": "1",
// "height": "842",
// "width": "595",
// "dpi": "72"
// }
// ],
// "availableDocumentTypes": [
// {
// "type": "electronic",
// "isDefault": "true"
// }
// ],
// "display": "inline",
// "includeInDownload": "true",
// "signerMustAcknowledge": "no_interaction",
// "templateRequired": "false",
// "authoritativeCopy": "false"
// },
// {
// "documentId": "certificate",
// "documentIdGuid": "7479a5de-8d91-44a2-bc33-b76a9ba0f6e2",
// "name": "Summary",
// "type": "summary",
// "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/certificate",
// "order": "999",
// "availableDocumentTypes": [
// {
// "type": "electronic",
// "isDefault": "true"
// }
// ],
// "display": "inline",
// "includeInDownload": "true",
// "signerMustAcknowledge": "no_interaction",
// "templateRequired": "false",
// "authoritativeCopy": "false"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
let mut j: i32 = 0;
let mut count_j: i32 = 0;
let envelope_id = j_resp.string_of("envelopeId").unwrap_or_default();
let mut i = 0;
let count_i = j_resp.size_of_array("envelopeDocuments");
while i < count_i {
j_resp.set_i(i);
let _ = j_resp.string_of("envelopeDocuments[i].documentId").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].documentIdGuid").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].name").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].type").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].uri").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].order").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].display").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].includeInDownload").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].signerMustAcknowledge").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].templateRequired").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].authoritativeCopy").unwrap_or_default();
j = 0;
count_j = j_resp.size_of_array("envelopeDocuments[i].pages");
while j < count_j {
j_resp.set_j(j);
let _ = j_resp.string_of("envelopeDocuments[i].pages[j].pageId").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].pages[j].sequence").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].pages[j].height").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].pages[j].width").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].pages[j].dpi").unwrap_or_default();
j = j + 1;
}
j = 0;
count_j = j_resp.size_of_array("envelopeDocuments[i].availableDocumentTypes");
while j < count_j {
j_resp.set_j(j);
let _ = j_resp.string_of("envelopeDocuments[i].availableDocumentTypes[j].type").unwrap_or_default();
let _ = j_resp.string_of("envelopeDocuments[i].availableDocumentTypes[j].isDefault").unwrap_or_default();
j = j + 1;
}
i = i + 1;
}