REST API for assigned media asset document

Contents

Repository setting

First of all, please active "Supports service API" for the "MediaAsset" field of the correponding PIM object–> mediaAssetMap entity, following image indicates the setting for Item(Article)–>Multimedia attachments(ArticleMediaAssetMap).MediaAsset
images/download/attachments/69406275/ArticleMediaAssetMap_mediaAsset.JPG

Assign a media asset file to PIM object

Follwing example shows how to Call REST List API methods to assgin a media asset file to PIM object.

This example assigns a media asset file(with identifier "D11000100112294") to the item(with item no. "test" of the supplier catalog "HMM test") by setting value of the fields ArticleMediaAssetDocument.Identifier for the primary keys(Type: others, Quality: originalimage, Language: english).

  • This REST call has just set the value to ArticleMediaAssetDocument.Identifier, all other furtrher logics about transition field "MediaAsset" are performed with the backend commandOperators mechanism.

  • This REST assigns a master asset in Informatica Media Manager (quality "originalimage") to an item, therefore all other exsiting derivatives of this asset will be also assigned automatically to the same item.

  • If there is already a media asset document assgined to the correpoding item before, it will be replaced without warning.

curl -u rest:heiler -H "Accept: application/json" -X POST http://localhost:1512/rest/V1.0/list/Article

The following JSON object is provided as content:

Assign HMM asset to item
{
"columns": [
{
"identifier": "ArticleMediaAssetDocument.Identifier(others, originalimage, english)"
}
],
"rows": [
{
"object": {
"id": "'test'@'HMM test'"
},
"values": [
"D11000100112294"
]
}
]
}

The same REST call works also for other media asset providers. E.g. for the classic provider, the following JSON object is provided as content where the media asset quality value as primary key should be adjusted with the corresponding enumeration entry .

Assign HLR asset to item
{
"columns": [
{
"identifier": "ArticleMediaAssetDocument.Identifier(others, web, english)"
}
],
"rows": [
{
"object": {
"id": "'item1'@'HLR test'"
},
"values": [
"hlr-system/ok.jpg"
]
}
]
}

Fetch the attributes of the media asset which is assigned to PIM object

The following Rest API gets the attributes(field value for WidthHMM and LastModifiedHMM) of the media asset documents(qualification: english, originalimage) belong to the media asset attachments which are assgined to the desired PIM object(item with item no. "200" in example).

  • The example uses "Rest Transition field" which is supported since PIM core 7.1.03.

  • The same REST LIST call for the entity Article also works for the corresponding attributes of other media asset providers(e.g. classic provider).

http://localhost:1512/rest/V1.0/list/Article/ArticleMediaAssetMap/bySearch?catalog=MASTER&query=Article.SupplierAID = "200" &fields=ArticleMediaAssetMap.MediaAsset->MediaAssetDocumentAttributes.WidthHMM(en, originalimage), ArticleMediaAssetMap.MediaAsset->MediaAssetDocumentAttributes.LastModifiedHMM(en, originalimage)

The following response shows all desired attributes:

images/download/attachments/69406301/image2015-6-10_17_23_57.png

Remove media asset attachment from PIM object

Since the Delete method for REST call is still not supported in the standard Product 360 for the transition field, the following steps should be performed consecutively:

The deletion sequence is important, please always delete the media asset map reference at first, then delete the MediaAsset entity object self. Otherwise the LastModified and Auditlog information of the corresponding PIM object will not be correctly updated.

Fetch the MediaAsset.Id which will be used for deletion of MediaAsset entity object

REST call
curl -u rest:heiler -H "Accept: application/json" -X GET
http://localhost:1512/rest/V1.0/list/Article/ArticleMediaAssetMap/bySearch?query=Article.SupplierAID%20=%20"ItemWithMediaAsset"&fields=ArticleMediaAssetMap.MediaAsset&qualificationFilter=mediaAssetType("Data sheet")

The returned protocol looks like

{
"cacheId": "20190711_125550_0",
"entityIdentifier": "ArticleMediaAssetMap",
"totalSize": 1,
"startIndex": 0,
"pageSize": 100,
"rowCount": 1,
"columnCount": 0,
"columns": [],
"rows": [
{
"object": {
"id": "25022@1",
"label": "ItemWithMediaAsset",
"entityId": 1000
},
"qualification": {
"mediaAssetType": "Data sheet"
},
"values": [
{
"id": "24745",
"label": "media asset attachment",
"entityId": 2400
}
]
}
]
}

Delete MediaAssetMap reference from object(e.g. item/product/variant)

REST call
curl -u rest:heiler -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -X DELETE http://localhost:1512/rest/V1.0/list/Article/ArticleMediaAssetMap/bySearch?query=Article.SupplierAID%20=%20"ItemWithMediaAsset"&qualificationFilter=mediaAssetType("Data sheet")

Delete MediaAsset entity object according to its id

REST call
curl -u rest:heiler -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -X DELETE http://localhost:1512/rest/V1.0/list/MediaAsset/bySearch?query=MediaAsset.Id%20=%2024745