Rust
Rust
Yousign: Download Information about Previously Uploaded File
See more Yousign Examples
Demonstrates how to download the information (in JSON format) about a file previously uploaded.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 CURL command:
// curl --location --request GET 'https://staging-api.yousign.com/files/{{id}}' \
// --header 'Authorization: Bearer YOUR_API_KEY' \
// --header 'Content-Type: application/json'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer YOUR_API_KEY" header.
http.set_auth_token("YOUR_API_KEY");
http.set_request_header("Content-Type", "application/json");
let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://staging-api.yousign.com/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", &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)
// {
// "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "The best name for my file.pdf",
// "type": "signable",
// "contentType": "application/pdf",
// "description": null,
// "createdAt": "2018-12-07T08:10:21+01:00",
// "updatedAt": "2018-12-07T08:10:21+01:00",
// "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2",
// "metadata": [
// ],
// "workspace": "/workspaces/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "creator": null,
// "protected": false,
// "position": 0,
// "parent": null
// }
// 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 id = j_resp.string_of("id").unwrap_or_default();
let name = j_resp.string_of("name").unwrap_or_default();
let v_type = j_resp.string_of("type").unwrap_or_default();
let content_type = j_resp.string_of("contentType").unwrap_or_default();
let description = j_resp.string_of("description").unwrap_or_default();
let created_at = j_resp.string_of("createdAt").unwrap_or_default();
let updated_at = j_resp.string_of("updatedAt").unwrap_or_default();
let sha256 = j_resp.string_of("sha256").unwrap_or_default();
let workspace = j_resp.string_of("workspace").unwrap_or_default();
let creator = j_resp.string_of("creator").unwrap_or_default();
let v_protected = j_resp.bool_of("protected");
let position = j_resp.int_of("position");
let parent = j_resp.string_of("parent").unwrap_or_default();
let mut i = 0;
let count_i = j_resp.size_of_array("metadata");
while i < count_i {
j_resp.set_i(i);
i = i + 1;
}