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

Akeneo: Create New Attribute Group

See more HTTP Misc Examples

Demonstrates how to create a new attribute group.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set http [new_CkHttp]

#  Use your previously obtained access token.
#  See Get Akeneo Access Token
CkHttp_put_AuthToken $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",
#  }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "code" "marketing"

CkJsonObject_put_EmitCompact $json 0
#  Show the JSON to be sent..
puts [CkJsonObject_emit $json]

set url "http://pim.my-akeneo-site.com/api/rest/v1/attribute-groups"
set resp [new_CkHttpResponse]

set success [CkHttp_HttpJson $http "POST" $url $json "application/json" $resp]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkHttpResponse $resp
    exit
}

#  Success is a 201 response status code with an empty body.
puts "Response Status Code: [CkHttpResponse_get_StatusCode $resp]"
puts "Response Body: "
puts [CkHttpResponse_bodyStr $resp]

delete_CkHttp $http
delete_CkJsonObject $json
delete_CkHttpResponse $resp