Sample code for 30+ languages & platforms
Rust Requires Chilkat v10.1.3+

Datev - Get a List of Clients

See more Datev Examples

Demonstrates how to get a list of clients in the accounting:clients Datev API.

Chilkat Rust Downloads

Rust

let http = chilkat::Http::new();

// Implements the following CURL command:

// curl --request GET \
//   --url "https://accounting-clients.api.datev.de/platform/v2/clients?filter=REPLACE_THIS_VALUE&skip=REPLACE_THIS_VALUE&top=REPLACE_THIS_VALUE" \
//   --header "Authorization: Bearer REPLACE_BEARER_TOKEN" \
//   --header "X-Datev-Client-ID: clientId" \
//   --header "accept: application/json;charset=utf-8"

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

let query_params = chilkat::JsonObject::new();
// ignore = queryParams.UpdateString("filter","REPLACE_THIS_VALUE");
// ignore = queryParams.UpdateString("skip","REPLACE_THIS_VALUE");
// ignore = queryParams.UpdateString("top","REPLACE_THIS_VALUE");

// Adds the "Authorization: Bearer REPLACE_BEARER_TOKEN" header.
http.set_auth_token("REPLACE_BEARER_TOKEN");
http.set_request_header("accept", "application/json;charset=utf-8");
http.set_request_header("X-Datev-Client-ID", "DATEV_CLIENT_ID");

let resp = chilkat::HttpResponse::new();
if http.http_params("GET", "https://accounting-clients.api.datev.de/platform-sandbox/v2/clients", &query_params, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

println!("{}", resp.status_code());
println!("{}", resp.body_str());

let jarr = chilkat::JsonArray::new();

// Insert code here to load the above JSON array into the jarr object.
let _ = jarr.load(&resp.body_str());

let mut j: i32 = 0;
let mut count_j: i32 = 0;
let mut k: i32 = 0;
let mut count_k: i32 = 0;

let mut i = 0;
let count_i = jarr.size();
while i < count_i {
    let json = jarr.object_at(i).unwrap();
    let _ = json.int_of("client_number");
    let _ = json.int_of("consultant_number");
    let _ = json.string_of("id").unwrap_or_default();
    let _ = json.string_of("name").unwrap_or_default();
    j = 0;
    count_j = json.size_of_array("services");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("services[j].name").unwrap_or_default();
        k = 0;
        count_k = json.size_of_array("services[j].scopes");
        while k < count_k {
            json.set_k(k);
            let _ = json.string_of("services[j].scopes[k]").unwrap_or_default();
            k = k + 1;
        }

        j = j + 1;
    }

    i = i + 1;
}