Sample code for 30+ languages & platforms
AutoIt

Akeneo: Create New Attribute

See more HTTP Misc Examples

Demonstrates how to create a new attribute.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oHttp = ObjCreate("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": "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"
;   }
; }

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("code","release_date")
$oJson.UpdateString("type","pim_catalog_date")
$oJson.UpdateString("group","marketing")
$oJson.UpdateBool("unique",False)
$oJson.UpdateBool("useable_as_grid_filter",True)
$oJson.UpdateNewArray("allowed_extensions")
$oJson.UpdateNull("metric_family")
$oJson.UpdateNull("default_metric_unit")
$oJson.UpdateNull("reference_data_name")
$oJson.UpdateNewArray("available_locales")
$oJson.UpdateNull("max_characters")
$oJson.UpdateNull("validation_rule")
$oJson.UpdateNull("validation_regexp")
$oJson.UpdateNull("wysiwyg_enabled")
$oJson.UpdateNull("number_min")
$oJson.UpdateNull("number_max")
$oJson.UpdateNull("decimals_allowed")
$oJson.UpdateNull("negative_allowed")
$oJson.UpdateString("date_min","2017-06-28T08:00:00")
$oJson.UpdateString("date_max","2017-08-08T22:00:00")
$oJson.UpdateNull("max_file_size")
$oJson.UpdateNull("minimum_input_length")
$oJson.UpdateNumber("sort_order","1")
$oJson.UpdateBool("localizable",False)
$oJson.UpdateBool("scopable",False)
$oJson.UpdateString("labels.en_US","Sale date")
$oJson.UpdateString("labels.fr_FR","Date des soldes")

$oJson.EmitCompact = False
; Show the JSON to be sent..
ConsoleWrite($oJson.Emit() & @CRLF)

Local $sUrl = "http://pim.my-akeneo-site.com/api/rest/v1/attributes"
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST",$sUrl,$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Response Status Code: " & $oResp.StatusCode & @CRLF)
ConsoleWrite("Response Body: " & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)