![]() |
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
(SQL Server) 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
-- 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.