Sample code for 30+ languages & platforms
AutoIt

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 AutoIt Downloads

AutoIt
Local $bSuccess = False

$oHttp = ObjCreate("Chilkat.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

$oQueryParams = ObjCreate("Chilkat.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.
$oHttp.AuthToken = "REPLACE_BEARER_TOKEN"
$oHttp.SetRequestHeader "accept","application/json;charset=utf-8"
$oHttp.SetRequestHeader "X-Datev-Client-ID","DATEV_CLIENT_ID"

$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpParams("GET","https://accounting-clients.api.datev.de/platform-sandbox/v2/clients",$oQueryParams,$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)

$oJarr = ObjCreate("Chilkat.JsonArray")

; Insert code here to load the above JSON array into the jarr object.
$oJarr.Load($oResp.BodyStr)

Local $oJson
Local $iClient_number
Local $iConsultant_number
Local $sId
Local $sName
Local $iJ
Local $iCount_j
Local $iK
Local $iCount_k
Local $strVal

Local $i = 0
Local $iCount_i = $oJarr.Size
While $i < $iCount_i
    $oJson = $oJarr.ObjectAt($i)
    $iClient_number = $oJson.IntOf("client_number")
    $iConsultant_number = $oJson.IntOf("consultant_number")
    $sId = $oJson.StringOf("id")
    $sName = $oJson.StringOf("name")
    $iJ = 0
    $iCount_j = $oJson.SizeOfArray("services")
    While $iJ < $iCount_j
        $oJson.J = $iJ
        $sName = $oJson.StringOf("services[j].name")
        $iK = 0
        $iCount_k = $oJson.SizeOfArray("services[j].scopes")
        While $iK < $iCount_k
            $oJson.K = $iK
            $strVal = $oJson.StringOf("services[j].scopes[k]")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend

    $i = $i + 1
Wend