REST Media Asset Category API
The REST Media Asset Category API provides access to media asset categories in the PIM Core.
Currently It is only supported by PIM Core with Media Manager.
Get Media Asset Category
URL Pattern |
/media/categories/{identifier} |
Method |
GET |
Parameters |
- |
Media types |
application/xml, application/json |
Returns |
the media asset category as MediaAssetCategory object |
Get top Media Asset Categories
URL Pattern |
/media/categories/ |
Method |
GET |
Parameters |
- |
Media types |
application/xml, application/json |
Returns |
all top media asset categories as a List of MediaAssetCategory objects |
Get direct child Media Asset Categories
URL Pattern |
/media/categories/{identifier}/categories |
Method |
GET |
Parameters |
- |
Media types |
application/xml, application/json |
Returns |
all direct child media asset categories as a List of MediaAssetCategory objects |
Add Media Asset Category
URL Pattern |
/media/categories |
Method |
POST |
Parameters |
parentId |
Media types |
application/xml, application/json |
Returns |
created media asset category as a MediaAssetCategory object |
The query parameter "parentId" is optional: if it is not set, then an new top category will be created, otherweis a child category will be created under the category with parentId.
Update Media Asset Category
URL Pattern |
/media/categories/{identifier} |
Method |
PUT |
Parameters |
- |
Media types |
application/xml, application/json |
Returns |
updated media asset category as a MediaAssetCategory object |
Delete Media Asset Category
URL Pattern |
/media/categories/{identifier} |
Method |
DELETE |
Parameters |
- |
Media types |
application/xml, application/json |
Returns |
string if media asset category is successfully deleted |
Examples
Retrieve single media asset category with identifier
curl -u rest:heiler -H
"Accept: application/json"
-H
"Accept-Language: de-DE"
-X GET http:
//localhost:1501/rest/V1.0/media/categories/000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
An object including an ID and an attributes which contains German name is returned:
{
"id"
:
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"attributes"
: {
"name"
:
"category_german"
,
"completeCategoryPath"
:
"/category_german"
,
"level"
:
1
,
"hasChildren"
:
true
}
}
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
String categoryId =
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
MediaAssetCategory category = mediaAssetCategoryRequest.getCategory( categoryId );
Retrieve all top media asset categories
curl -u rest:heiler -H
"Accept: application/json"
-X GET http:
//localhost:1501/rest/V1.0/media/categories
The following JSON objec is returned:
[
{
"id"
:
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"attributes"
: {
"name"
:
"category_german"
,
"completeCategoryPath"
:
"/category_german"
,
"level"
:
1
,
"hasChildren"
:
true
}
},
{
"id"
:
"000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"attributes"
: {
"name"
:
"category2"
,
"completeCategoryPath"
:
"/category2"
,
"level"
:
1
,
"hasChildren"
:
false
}
}
]
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
List< MediaAssetCategory > topCategories = mediaAssetCategoryRequest.getCategories( );
Retrieve all direct child media asset categories of the category with identifier
curl -u rest:heiler -H
"Accept: application/json"
-X GET http:
//localhost:1501/rest/V1.0/media/categories/000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/categories
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
String categoryId =
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
List< MediaAssetCategory > childCategories = mediaAssetCategoryRequest.getCategories( categoryId );
Add a top media asset category
curl -u rest:heiler -H
"Accept: application/json"
-X POST http:
//localhost:1501/rest/V1.0/media/categories
The following JSON object is provided as content:
{
"name"
:
"newTopCategory"
}
The following JSON objec is returned:
{
"id"
:
"000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"attributes"
: {
"name"
:
"newTopCategory"
,
"completeCategoryPath"
:
"/newTopCategory"
,
"level"
:
1
,
"hasChildren"
:
false
}
}
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
MediaAssetCategoryAttributes categoryAttributes =
new
MediaAssetCategoryAttributes( );
categoryAttributes.setName(
"newTopCategory"
);
MediaAssetCategory topCategory = mediaAssetCategoryRequest.addCategory( categoryAttributes );
Add a child media asset category under the category with identifier
curl -u rest:heiler -H
"Accept: application/json"
-X POST http:
//localhost:1501/rest/V1.0/media/categories/?parentId=000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
String parentId =
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
MediaAssetCategoryAttributes categoryAttributes =
new
MediaAssetCategoryAttributes( );
categoryAttributes.setName(
"newSubCategory"
);
MediaAssetCategory subCategory= mediaAssetCategoryRequest.addCategory( parentId, categoryAttributes );
Update the name of the media asset category with identifier
curl -u rest:heiler -H
"Accept: application/json"
-X PUT http:
//localhost:1501/rest/V1.0/media/categories/000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
The following JSON object is provided as content:
{
"name"
:
"newCategoryName"
}
The following JSON objec is returned:
{
"id"
:
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
,
"attributes"
: {
"name"
:
"newCategoryName"
,
"completeCategoryPath"
:
"/newCategoryName"
,
"level"
:
1
,
"hasChildren"
:
true
}
}
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
String categoryId =
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
MediaAssetCategoryAttributes categoryAttributes =
new
MediaAssetCategoryAttributes( );
categoryAttributes.setName(
"newCategoryName"
);
MediaAssetCategory updatedCategory= mediaAssetCategoryRequest.updateCategory( categoryId, categoryAttributes );
Delete a media asset category with identifier
curl -u rest:heiler -H
"Accept: application/json"
-X DELETE http:
//localhost:1501/rest/V1.0/media/categories/000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
MediaAssetCategoryRequest mediaAssetCategoryRequest = restClient.createMediaRequest().createCategoryRequest();
String categoryId =
"000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
String removed = mediaAssetCategoryRequest.removeCategory( categoryId );