Visual FoxPro
Visual FoxPro
Akeneo: Create New Family
See more HTTP Misc Examples
Demonstrates how to create a new family.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL loJson
LOCAL lcUrl
LOCAL loResp
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* Use your previously obtained access token.
* See Get Akeneo Access Token
loHttp.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": "caps",
* "attributes": [
* "sku",
* "name",
* "description",
* "price",
* "color",
* "picture"
* ],
* "attribute_as_label": "name",
* "attribute_as_image": "picture",
* "attribute_requirements": {
* "ecommerce": [
* "sku",
* "name",
* "description",
* "price",
* "color"
* ],
* "tablet": [
* "sku",
* "name",
* "description",
* "price"
* ]
* },
* "labels": {
* "en_US": "Caps",
* "fr_FR": "Casquettes"
* }
* }
*
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("code","caps")
loJson.UpdateString("attributes[0]","sku")
loJson.UpdateString("attributes[1]","name")
loJson.UpdateString("attributes[2]","description")
loJson.UpdateString("attributes[3]","price")
loJson.UpdateString("attributes[4]","color")
loJson.UpdateString("attributes[5]","picture")
loJson.UpdateString("attribute_as_label","name")
loJson.UpdateString("attribute_as_image","picture")
loJson.UpdateString("attribute_requirements.ecommerce[0]","sku")
loJson.UpdateString("attribute_requirements.ecommerce[1]","name")
loJson.UpdateString("attribute_requirements.ecommerce[2]","description")
loJson.UpdateString("attribute_requirements.ecommerce[3]","price")
loJson.UpdateString("attribute_requirements.ecommerce[4]","color")
loJson.UpdateString("attribute_requirements.tablet[0]","sku")
loJson.UpdateString("attribute_requirements.tablet[1]","name")
loJson.UpdateString("attribute_requirements.tablet[2]","description")
loJson.UpdateString("attribute_requirements.tablet[3]","price")
loJson.UpdateString("labels.en_US","Caps")
loJson.UpdateString("labels.fr_FR","Casquettes")
loJson.EmitCompact = 0
* Show the JSON to be sent..
? loJson.Emit()
lcUrl = "http://pim.my-akeneo-site.com/api/rest/v1/families"
loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpJson("POST",lcUrl,loJson,"application/json",loResp)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loResp
CANCEL
ENDIF
? "Response Status Code: " + STR(loResp.StatusCode)
? "Response Body: "
? loResp.BodyStr
RELEASE loHttp
RELEASE loJson
RELEASE loResp