Create and update Categories in your Project.
The Category data to import is represented by CategoryImport and included in a CategoryImportRequest, which is imported using Import Categories.
Representations
CategoryImportRequest
The request body to import Categories. Contains data for Categories to be created or updated in a Project.
type | category The resource types that can be imported. |
resources Array of CategoryImport | The category import resources of this request. MaxItems:20 |
{
"type": "category",
"resources": [
{
"key": "category-to-import",
"name": {
"en": "Category to import"
},
"slug": {
"en": "category-to-import-slug"
},
"description": {
"en": "Description of category to import"
},
"parent": {
"typeId": "category",
"key": "key-of-parent-category"
}
}
]
}
CategoryImport
The data representation for a Category to be imported that is persisted as a Category in the Project.
key String | User-defined unique identifier. If a Category with this MinLength: key exists, it will be updated with the imported data.2 MaxLength: 256 Pattern: ^[A-Za-z0-9_-]+$ |
externalId String | Maps to Category.externalId . |
name | Maps to Category.name . |
slug | Maps to Category.slug .
Must match the pattern [-a-zA-Z0-9_]{2,256} . |
description | Maps to Category.description . |
parent | Maps to Category.parent .
The Reference to the parent Category with which the Category is associated.
If referenced Category does not exist, the state of the ImportOperation will be set to unresolved until the necessary Category is created. |
orderHint String | Maps to Category.orderHint . |
metaTitle | Maps to Category.metaTitle . |
metaDescription | Maps to Category.metaDescription . |
metaKeywords | Maps to Category.metaKeywords . |
assets Array of Asset | Maps to Category.assets . |
custom | The custom fields for this Category. |
{
"key": "category-to-import",
"name": {
"en": "Category to import"
},
"slug": {
"en": "category-to-import-slug"
},
"description": {
"en": "Description of category to import"
},
"parent": {
"typeId": "category",
"key": "key-of-parent-category"
}
}
Import Categories
POST
https://import.{region}.commercetools.com/{projectKey}/categories/import-containers/{importContainerKey}
Creates a request for creating new Categories or updating existing ones.
OAuth 2.0 Scopes:
manage_products:{projectKey}
Path parameters:
region String | The Region in which the Project is hosted. |
projectKey String | The Project key. |
importContainerKey String | The ImportContainer used to create the new resource |
Request Body:CategoryImportRequestas
application/json
Response:
201as
application/json
curl https://import.{region}.commercetools.com/{projectKey}/categories/import-containers/{importContainerKey} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"type" : "category",
"resources" : [ {
"key" : "category-to-import",
"name" : {
"en" : "Category to import"
},
"slug" : {
"en" : "category-to-import-slug"
},
"description" : {
"en" : "Description of category to import"
},
"parent" : {
"typeId" : "category",
"key" : "key-of-parent-category"
}
} ]
}
DATA
{
"operationStatus": [
{
"state": "processing",
"operationId": "252c6ed3-c668-4610-afe9-87b9255e62e0"
}
]
}