Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Akeneo: Create New Attribute Group

See more HTTP Misc Examples

Demonstrates how to create a new attribute group.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oJson
LOCAL cUrl
LOCAL oResp

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("Chilkat.Http")

//  Use your previously obtained access token.
//  See Get Akeneo Access Token
oHttp: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": "marketing",
//  }

oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("code", "marketing")

oJson:EmitCompact := 0
//  Show the JSON to be sent..
? oJson:Emit()

cUrl := "http://pim.my-akeneo-site.com/api/rest/v1/attribute-groups"
oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpJson("POST", cUrl, oJson, "application/json", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oJson:destroy()
    oResp:destroy()
    RETURN
ENDIF

//  Success is a 201 response status code with an empty body.
? "Response Status Code: " + Str(oResp:StatusCode)
? "Response Body: "
? oResp:BodyStr

oHttp:destroy()
oJson:destroy()
oResp:destroy()