Skip to content

Instantly share code, notes, and snippets.

@arfaram
Created December 12, 2018 18:14
Show Gist options
  • Save arfaram/559dab9c210e5d529cf03b67bdd9a70c to your computer and use it in GitHub Desktop.
Save arfaram/559dab9c210e5d529cf03b67bdd9a70c to your computer and use it in GitHub Desktop.
Create ezcommerce product using the eZ Platform Rest API
POST /api/ezp/v2/content/objects HTTP/1.1
Host: www.ezcomerce_demo.local
Accept: application/vnd.ez.api.Content+xml
X-CSRF-Token: S0s-myzSK5NHB5JMMrhTvRozEL0Jn3tl5QdjpWXyOt0
Content-Type: application/vnd.ez.api.ContentCreate+json
{
"ContentCreate": {
"ContentType": {
"_href": "/api/ezp/v2/content/types/44"
},
"mainLanguageCode": "eng-GB",
"LocationCreate": {
"ParentLocation": {
"_href": "/api/ezp/v2/content/locations/1/2/56/252/255"
},
"priority": "0",
"hidden": false,
"sortField": "PATH",
"sortOrder": "ASC"
},
"Section": {
"_href": "/api/ezp/v2/content/sections/4"
},
"alwaysAvailable": true,
"remoteId": "",
"fields": {
"field": [
{
"fieldDefinitionIdentifier": "ses_name",
"languageCode": "eng-GB",
"fieldValue": "This is a new microwave4"
},
{
"fieldDefinitionIdentifier": "ses_specifications",
"languageCode": "eng-GB",
"fieldValue": "[{\"name\":\"marketing\",\"data\":[{\"label\":\"Brand\",\"value\":\"MG\"},{\"label\":\"Warranty\",\"value\":\"2yrs\"}]},{\"name\":\"technic\",\"data\":[{\"label\":\"Size\",\"value\":\"12cm\"},{\"label\":\"color\",\"value\":\"red\"}]},{\"name\":\"norms\",\"data\":[{\"label\":\"Manufacturer\",\"value\":\"Triple B\"},{\"label\":\"color\",\"value\":\"blue\"}]}]"
},
{
"fieldDefinitionIdentifier": "ses_sku",
"languageCode": "eng-GB",
"fieldValue": "1220"
},
{
"fieldDefinitionIdentifier": "ses_variants",
"languageCode": "eng-GB",
"fieldValue": "[{\"sku\":{\"label\":\"Sku\",\"value\":\"5515\"},\"variantCode\":{\"label\":\"Variant Code\",\"value\":\"5515\"},\"description\":{\"label\":\"Description\",\"value\":\"Alibaba Single Door Silver Refrigerator\"},\"characteristicCode1\":{\"label\":\"22\\\"\",\"value\":\"22\\\"\"},\"characteristicLabel1\":{\"label\":\"Color\",\"value\":\"Color\"},\"characteristicCode2\":{\"label\":\"Silver\",\"value\":\"Silver\"},\"characteristicLabel2\":{\"label\":\"\",\"value\":\"\"},\"priceNet\":{\"label\":\"Listprice net\",\"value\":\"220\"},\"vatPercent\":{\"label\":\"VAT percent\",\"value\":\"\"},\"dataMap_countryOfOrigin\":{\"label\":\"dataMap Country of Origin\",\"value\":\"\"}},{\"sku\":{\"label\":\"Sku\",\"value\":\"5515\"},\"variantCode\":{\"label\":\"Variant Code\",\"value\":\"\"},\"description\":{\"label\":\"Description\",\"value\":\"Alibaba Single Door Silver Refrigerator\"},\"characteristicCode1\":{\"label\":\"22\\\"\",\"value\":\"22\\\"\"},\"characteristicLabel1\":{\"label\":\"Size\",\"value\":\"Size\"},\"characteristicCode2\":{\"label\":\"Silver\",\"value\":\"Silver\"},\"characteristicLabel2\":{\"label\":\"Color\",\"value\":\"Color\"},\"priceNet\":{\"label\":\"Listprice net\",\"value\":\"220\"},\"vatPercent\":{\"label\":\"VAT percent\",\"value\":\"\"},\"dataMap_countryOfOrigin\":{\"label\":\"dataMap Country of Origin\",\"value\":\"\"}},{\"sku\":{\"label\":\"Sku\",\"value\":\"5515\"},\"variantCode\":{\"label\":\"Variant Code\",\"value\":\"5532\"},\"description\":{\"label\":\"Description\",\"value\":\"Alibaba Single Door Silver Refrigerator\"},\"characteristicCode1\":{\"label\":\"30\\\"\",\"value\":\"30\\\"\"},\"characteristicLabel1\":{\"label\":\"Size\",\"value\":\"Size\"},\"characteristicCode2\":{\"label\":\"White\",\"value\":\"White\"},\"characteristicLabel2\":{\"label\":\"Color\",\"value\":\"Color\"},\"priceNet\":{\"label\":\"Listprice net\",\"value\":\"330\"},\"vatPercent\":{\"label\":\"VAT percent\",\"value\":\"\"},\"dataMap_countryOfOrigin\":{\"label\":\"dataMap Country of Origin\",\"value\":\"\"}}]"
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment