Rust
Rust
Yousign: List Files
See more Yousign Examples
List Yousign files.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' \
// --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", &sb_response_body).is_err() {
println!("{}", http.last_error_text());
return;
}
let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_response_body);
json.set_emit_compact(false);
println!("Response Body:");
println!("{}", json.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": "abc.pdf",
// "type": "signable",
// "contentType": "application\/pdf",
// "description": null,
// "createdAt": "2020-05-27T09:14:12+02:00",
// "updatedAt": "2020-05-27T09:14:12+02:00",
// "sha256": "ea2a92b0eff5bebfa3ccd869fd61e27bb7fe973d0dff63f106d8b0d614469fa0",
// "metadata": [
// ],
// "workspace": "\/workspaces\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "creator": null,
// "fileObjects": [
// ],
// "protected": false,
// "position": 0,
// "parent": null,
// "fieldsCompatible": true,
// "company": "\/companies\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
// }
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
let id = json.string_of("id").unwrap_or_default();
let name = json.string_of("name").unwrap_or_default();
let v_type = json.string_of("type").unwrap_or_default();
let content_type = json.string_of("contentType").unwrap_or_default();
let description = json.string_of("description").unwrap_or_default();
let created_at = json.string_of("createdAt").unwrap_or_default();
let updated_at = json.string_of("updatedAt").unwrap_or_default();
let sha256 = json.string_of("sha256").unwrap_or_default();
let workspace = json.string_of("workspace").unwrap_or_default();
let creator = json.string_of("creator").unwrap_or_default();
let v_protected = json.bool_of("protected");
let position = json.int_of("position");
let parent = json.string_of("parent").unwrap_or_default();
let fields_compatible = json.bool_of("fieldsCompatible");
let company = json.string_of("company").unwrap_or_default();
let mut i = 0;
let mut count_i = json.size_of_array("metadata");
while i < count_i {
json.set_i(i);
i = i + 1;
}
i = 0;
count_i = json.size_of_array("fileObjects");
while i < count_i {
json.set_i(i);
i = i + 1;
}