![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Datev - Get a List of ClientsSee more Datev ExamplesDemonstrates how to get a list of clients in the accounting:clients Datev API.Note: This example requires Chilkat v10.1.3 or greater. For more information, see https://developer.datev.de/en/product-detail/accounting-clients/2.0/reference/reference-api-overview/accountingclients/clients-get
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonArray.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; 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 queryParams.i = CkJsonObject::ckCreate() If queryParams.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; 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. CkHttp::setCkAuthToken(http, "REPLACE_BEARER_TOKEN") CkHttp::ckSetRequestHeader(http,"accept","application/json;charset=utf-8") CkHttp::ckSetRequestHeader(http,"X-Datev-Client-ID","DATEV_CLIENT_ID") resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://accounting-clients.api.datev.de/platform-sandbox/v2/clients",queryParams) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(queryParams) ProcedureReturn EndIf Debug Str(CkHttpResponse::ckStatusCode(resp)) Debug CkHttpResponse::ckBodyStr(resp) jarr.i = CkJsonArray::ckCreate() If jarr.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Insert code here to load the above JSON array into the jarr object. CkJsonArray::ckLoad(jarr,CkHttpResponse::ckBodyStr(resp)) CkHttpResponse::ckDispose(resp) json.i client_number.i consultant_number.i id.s name.s j.i count_j.i k.i count_k.i strVal.s i.i = 0 count_i.i = CkJsonArray::ckSize(jarr) While i < count_i json = CkJsonArray::ckObjectAt(jarr,i) client_number = CkJsonObject::ckIntOf(json,"client_number") consultant_number = CkJsonObject::ckIntOf(json,"consultant_number") id = CkJsonObject::ckStringOf(json,"id") name = CkJsonObject::ckStringOf(json,"name") j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"services") While j < count_j CkJsonObject::setCkJ(json, j) name = CkJsonObject::ckStringOf(json,"services[j].name") k = 0 count_k = CkJsonObject::ckSizeOfArray(json,"services[j].scopes") While k < count_k CkJsonObject::setCkK(json, k) strVal = CkJsonObject::ckStringOf(json,"services[j].scopes[k]") k = k + 1 Wend j = j + 1 Wend CkJsonObject::ckDispose(json) i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(queryParams) CkJsonArray::ckDispose(jarr) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.