Sample code for 30+ languages & platforms
Dart 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 Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final http = CkHttp();

  // 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

  final queryParams = CkJsonObject();
  // 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.authToken = 'REPLACE_BEARER_TOKEN';
  http.setRequestHeader('accept', 'application/json;charset=utf-8');
  http.setRequestHeader('X-Datev-Client-ID', 'DATEV_CLIENT_ID');

  final resp = CkHttpResponse();
  try {
    http.httpParams('GET', 'https://accounting-clients.api.datev.de/platform-sandbox/v2/clients', queryParams, resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print(resp.statusCode);
  print(resp.bodyStr);

  final jarr = CkJsonArray();

  // Insert code here to load the above JSON array into the jarr object.
  jarr.load(resp.bodyStr);

  var clientNumber = 0;
  var consultantNumber = 0;
  var id = '';
  var name = '';
  var j = 0;
  var countJ = 0;
  var k = 0;
  var countK = 0;
  var strVal = '';

  var i = 0;
  final countI = jarr.size;
  while (i < countI) {
    final json = jarr.objectAt(i);
    clientNumber = json.intOf('client_number');
    consultantNumber = json.intOf('consultant_number');
    id = json.stringOf('id');
    name = json.stringOf('name');
    j = 0;
    countJ = json.sizeOfArray('services');
    while (j < countJ) {
      json.j = j;
      name = json.stringOf('services[j].name');
      k = 0;
      countK = json.sizeOfArray('services[j].scopes');
      while (k < countK) {
        json.k = k;
        strVal = json.stringOf('services[j].scopes[k]');
        k++;
      }

      j++;
    }

    i++;
  }
}