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) Akeneo: Create New AttributeDemonstrates how to create a new attribute.
-- 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) -- This example requires 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 -- Use your previously obtained access token. -- See Get Akeneo Access Token EXEC sp_OASetProperty @http, 'AuthToken', 'access_token' -- Build the following JSON to be sent in the request body: -- Use this online tool to generate the code from sample JSON: -- Generate Code to Create JSON -- { -- "code": "release_date", -- "type": "pim_catalog_date", -- "group": "marketing", -- "unique": false, -- "useable_as_grid_filter": true, -- "allowed_extensions": [], -- "metric_family": null, -- "default_metric_unit": null, -- "reference_data_name": null, -- "available_locales": [], -- "max_characters": null, -- "validation_rule": null, -- "validation_regexp": null, -- "wysiwyg_enabled": null, -- "number_min": null, -- "number_max": null, -- "decimals_allowed": null, -- "negative_allowed": null, -- "date_min": "2017-06-28T08:00:00", -- "date_max": "2017-08-08T22:00:00", -- "max_file_size": null, -- "minimum_input_length": null, -- "sort_order": 1, -- "localizable": false, -- "scopable": false, -- "labels": { -- "en_US": "Sale date", -- "fr_FR": "Date des soldes" -- } -- } DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT DECLARE @success int EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'code', 'release_date' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'type', 'pim_catalog_date' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'group', 'marketing' EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'unique', 0 EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'useable_as_grid_filter', 1 EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'allowed_extensions' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'metric_family' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'default_metric_unit' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'reference_data_name' EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'available_locales' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'max_characters' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'validation_rule' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'validation_regexp' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'wysiwyg_enabled' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'number_min' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'number_max' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'decimals_allowed' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'negative_allowed' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'date_min', '2017-06-28T08:00:00' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'date_max', '2017-08-08T22:00:00' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'max_file_size' EXEC sp_OAMethod @json, 'UpdateNull', @success OUT, 'minimum_input_length' EXEC sp_OAMethod @json, 'UpdateNumber', @success OUT, 'sort_order', '1' EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'localizable', 0 EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'scopable', 0 EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'labels.en_US', 'Sale date' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'labels.fr_FR', 'Date des soldes' EXEC sp_OASetProperty @json, 'EmitCompact', 0 -- Show the JSON to be sent.. EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @url nvarchar(4000) SELECT @url = 'http://pim.my-akeneo-site.com/api/rest/v1/attributes' DECLARE @resp int EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, @url, 'application/json', @json EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json RETURN END EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT PRINT 'Response Status Code: ' + @iTmp0 PRINT 'Response Body: ' EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @resp EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @json END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.