Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Shopware List CategoriesSee more Shopware ExamplesList categories in your Shopware database. For more information, see https://developers.shopware.com/developers-guide/rest-api/api-resource-categories/
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. 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 EXEC sp_OASetProperty @http, 'Login', 'api_username' EXEC sp_OASetProperty @http, 'Password', 'api_key' EXEC sp_OASetProperty @http, 'BasicAuth', 1 DECLARE @sbResponseBody int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT DECLARE @success int EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://my-shopware-shop.com/api/categories?limit=2', @sbResponseBody IF @success = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbResponseBody RETURN END DECLARE @jResp int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody EXEC sp_OASetProperty @jResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 -- Sample JSON response: -- (Sample code for parsing the JSON response is shown below) -- { -- "data": [ -- { -- "id": 1, -- "active": true, -- "name": "Root", -- "position": 0, -- "parentId": null, -- "mediaId": null, -- "childrenCount": "3", -- "articleCount": "0" -- }, -- { -- "id": 384, -- "active": true, -- "name": "Deutsch", -- "position": 0, -- "parentId": 1, -- "mediaId": null, -- "childrenCount": "9", -- "articleCount": "32" -- } -- ], -- "total": 118, -- "success": true -- } -- Sample code for parsing the JSON response... -- Use the following online tool to generate parsing code from sample JSON: -- Generate Parsing Code from JSON DECLARE @id int DECLARE @active int DECLARE @name nvarchar(4000) DECLARE @position int DECLARE @parentId nvarchar(4000) DECLARE @mediaId nvarchar(4000) DECLARE @childrenCount nvarchar(4000) DECLARE @articleCount nvarchar(4000) DECLARE @total int EXEC sp_OAMethod @jResp, 'IntOf', @total OUT, 'total' DECLARE @success int EXEC sp_OAMethod @jResp, 'BoolOf', @success OUT, 'success' DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'data' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i EXEC sp_OAMethod @jResp, 'IntOf', @id OUT, 'data[i].id' EXEC sp_OAMethod @jResp, 'BoolOf', @active OUT, 'data[i].active' EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'data[i].name' EXEC sp_OAMethod @jResp, 'IntOf', @position OUT, 'data[i].position' EXEC sp_OAMethod @jResp, 'StringOf', @parentId OUT, 'data[i].parentId' EXEC sp_OAMethod @jResp, 'StringOf', @mediaId OUT, 'data[i].mediaId' EXEC sp_OAMethod @jResp, 'StringOf', @childrenCount OUT, 'data[i].childrenCount' EXEC sp_OAMethod @jResp, 'StringOf', @articleCount OUT, 'data[i].articleCount' SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.