Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Examples
Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(SQL Server) Datev - Get a List of Clients

See more Datev Examples
Demonstrates 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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

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

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    -- 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.
    EXEC sp_OASetProperty @http, 'AuthToken', 'REPLACE_BEARER_TOKEN'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'accept', 'application/json;charset=utf-8'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-Datev-Client-ID', 'DATEV_CLIENT_ID'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://accounting-clients.api.datev.de/platform-sandbox/v2/clients', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @jarr int
    -- Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarr OUT

    -- Insert code here to load the above JSON array into the jarr object.
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    EXEC sp_OAMethod @jarr, 'Load', @success OUT, @sTmp0
    EXEC @hr = sp_OADestroy @resp

    DECLARE @json int

    DECLARE @client_number int

    DECLARE @consultant_number int

    DECLARE @id nvarchar(4000)

    DECLARE @name nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @k int

    DECLARE @count_k int

    DECLARE @strVal nvarchar(4000)

    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAGetProperty @jarr, 'Size', @count_i OUT
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OAMethod @jarr, 'ObjectAt', @json OUT, @i
        EXEC sp_OAMethod @json, 'IntOf', @client_number OUT, 'client_number'
        EXEC sp_OAMethod @json, 'IntOf', @consultant_number OUT, 'consultant_number'
        EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id'
        EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'name'
        SELECT @j = 0
        EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'services'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @json, 'J', @j
            EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'services[j].name'
            SELECT @k = 0
            EXEC sp_OAMethod @json, 'SizeOfArray', @count_k OUT, 'services[j].scopes'
            WHILE @k < @count_k
              BEGIN
                EXEC sp_OASetProperty @json, 'K', @k
                EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'services[j].scopes[k]'
                SELECT @k = @k + 1
              END
            SELECT @j = @j + 1
          END
        EXEC @hr = sp_OADestroy @json

        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams
    EXEC @hr = sp_OADestroy @jarr


END
GO

 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.