Delphi DLL
Delphi DLL
Akeneo: Create New Attribute Group
See more HTTP Misc Examples
Demonstrates how to create a new attribute group.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, HttpResponse, JsonObject;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
json: HCkJsonObject;
url: PWideChar;
resp: HCkHttpResponse;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
// Use your previously obtained access token.
// See Get Akeneo Access Token
CkHttp_putAuthToken(http,'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": "marketing",
// }
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'code','marketing');
CkJsonObject_putEmitCompact(json,False);
// Show the JSON to be sent..
Memo1.Lines.Add(CkJsonObject__emit(json));
url := 'http://pim.my-akeneo-site.com/api/rest/v1/attribute-groups';
resp := CkHttpResponse_Create();
success := CkHttp_HttpJson(http,'POST',url,json,'application/json',resp);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
// Success is a 201 response status code with an empty body.
Memo1.Lines.Add('Response Status Code: ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add('Response Body: ');
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkHttpResponse_Dispose(resp);
end;