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
(Unicode C) Akeneo: Create New AttributeDemonstrates how to create a new attribute.
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; HCkJsonObjectW json; const wchar_t *url; HCkHttpResponseW resp; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Use your previously obtained access token. // See Get Akeneo Access Token CkHttpW_putAuthToken(http,L"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" // } // } json = CkJsonObjectW_Create(); CkJsonObjectW_UpdateString(json,L"code",L"release_date"); CkJsonObjectW_UpdateString(json,L"type",L"pim_catalog_date"); CkJsonObjectW_UpdateString(json,L"group",L"marketing"); CkJsonObjectW_UpdateBool(json,L"unique",FALSE); CkJsonObjectW_UpdateBool(json,L"useable_as_grid_filter",TRUE); CkJsonObjectW_UpdateNewArray(json,L"allowed_extensions"); CkJsonObjectW_UpdateNull(json,L"metric_family"); CkJsonObjectW_UpdateNull(json,L"default_metric_unit"); CkJsonObjectW_UpdateNull(json,L"reference_data_name"); CkJsonObjectW_UpdateNewArray(json,L"available_locales"); CkJsonObjectW_UpdateNull(json,L"max_characters"); CkJsonObjectW_UpdateNull(json,L"validation_rule"); CkJsonObjectW_UpdateNull(json,L"validation_regexp"); CkJsonObjectW_UpdateNull(json,L"wysiwyg_enabled"); CkJsonObjectW_UpdateNull(json,L"number_min"); CkJsonObjectW_UpdateNull(json,L"number_max"); CkJsonObjectW_UpdateNull(json,L"decimals_allowed"); CkJsonObjectW_UpdateNull(json,L"negative_allowed"); CkJsonObjectW_UpdateString(json,L"date_min",L"2017-06-28T08:00:00"); CkJsonObjectW_UpdateString(json,L"date_max",L"2017-08-08T22:00:00"); CkJsonObjectW_UpdateNull(json,L"max_file_size"); CkJsonObjectW_UpdateNull(json,L"minimum_input_length"); CkJsonObjectW_UpdateNumber(json,L"sort_order",L"1"); CkJsonObjectW_UpdateBool(json,L"localizable",FALSE); CkJsonObjectW_UpdateBool(json,L"scopable",FALSE); CkJsonObjectW_UpdateString(json,L"labels.en_US",L"Sale date"); CkJsonObjectW_UpdateString(json,L"labels.fr_FR",L"Date des soldes"); CkJsonObjectW_putEmitCompact(json,FALSE); // Show the JSON to be sent.. wprintf(L"%s\n",CkJsonObjectW_emit(json)); url = L"http://pim.my-akeneo-site.com/api/rest/v1/attributes"; resp = CkHttpW_PostJson3(http,url,L"application/json",json); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); return; } wprintf(L"Response Status Code: %d\n",CkHttpResponseW_getStatusCode(resp)); wprintf(L"Response Body: \n"); wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp)); CkHttpResponseW_Dispose(resp); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.