React Native Requires Chilkat v10.1.3+
React Native
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 React Native Downloads
import { Http, HttpResponse, JsonArray, JsonObject } from '@chilkat/react-native'
async function chilkatExample() {
const http = new Http();
// 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
const queryParams = new JsonObject();
// 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');
const resp = new HttpResponse();
try {
await http.httpParamsAsync('GET', 'https://accounting-clients.api.datev.de/platform-sandbox/v2/clients', queryParams, resp);
} catch {
console.log(http.lastErrorText);
return;
}
console.log(resp.statusCode);
console.log(resp.bodyStr);
const jarr = new JsonArray();
// Insert code here to load the above JSON array into the jarr object.
jarr.load(resp.bodyStr);
let clientNumber = 0;
let consultantNumber = 0;
let id = '';
let name = '';
let j = 0;
let countJ = 0;
let k = 0;
let countK = 0;
let strVal = '';
let i = 0;
const countI = jarr.size;
while (i < countI) {
const 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++;
}
}