REST API how to create an assignment of media asset to an article

Introduction

To create an assignment between a media asset and an item you can use a POST REST call. The next two screens shows what has happened in the desktop client before and after called the REST call.

All following examples show different cases with a media asset from Informatica Media Manager, but the same REST LIST API for the entity Article and MediaAsset work also for other providers(e.g. Classic provider), while the REST LIST API for the entity MediaAssetFile is only for Informatica Media Manager.

Before:
images/download/attachments/82641796/image2016-1-28_14_10_4.png

After:
images/download/attachments/82641796/image2016-1-28_14_8_41.png

Other names for an assignment can be a combination of 'multimedia' or 'media asset' and 'attachment' or 'document',

In the following parts of these page some values are bold and colored. These are key values for the REST Calls. See here what the different colors means.

Color markers

internal article ID

internal media asset ID (from Media Manager), or media asset file ID in PIM

assignement ID (Media Asset Document)

additional required parameter for assignment

parameter for other requests

Create an assignment of media asset to an item

This is the REST call to create the assignment. The body of this POST is formatted in JSON. The blue parts are fixed values in this example.

Call text

Explanation

others

  • type of assignment

  • has to be an item of a list defined in the repository (i.e. 'normal', 'thumbnail', 'data_sheet', 'logo', 'others', 'unknown' )

originalimage

  • quality of assignment

  • it is possible to enter a derivative of an asset here as defined in the hmm.properties

  • in most cases use 'originalimage' as value

Englisch

created by rest call

  • name of the attachment

  • all text values are allowed here

The IDs for the item and the media asset come from other request.

Call text

Explanation

18503@1

D120001189316

  • media asset ID from Media Manager

  • this ID always starts with a 'D'

  • you can copy this ID from clients or use the REST call described here: Search for Media Assets

POST Body

{
"columns": [
{
"identifier": "ArticleMediaAssetDocument.Identifier( others , originalimage , Englisch )",
"identifier": "ArticleMediaAssetMap.Name( others )"
}
],
"rows": [
{
"object": {
"id": " 18503@1 "
},
"values": [
" D120001189316 "
],
"values": [
" created by rest call "
]
}
]
}

Response

{
"counters": {
"errors": 0,
"warnings": 0,
"createdObjects": 0,
"updatedObjects": 1,
"objectsWithErrors": 0,
"objectsWithWarnings": 0
},
"entries": [],
"objects": [
{
"row": 0,
"object": {
"id": " 18503@1 ",
"label": "robustnessdeep0011"
},
"status": [
"UPDATED"
]
}
]
}

Search for ids of items

You need the internal ID of an item to create an assignment for it. The following request i.e. list this id. In this case the 'item no.' is given.

images/download/attachments/82641796/image2016-1-28_10_53_59.png

Response

{
"cacheId": "20160128_104504_0",
"entityIdentifier": "Article",
"totalSize": 1,
"startIndex": 0,
"pageSize": 100,
"rowCount": 1,
"columnCount": 0,
"columns": [],
"rows": [
{
"object": {
"id": " 103@1 ",
"label": " Article_85275762972671 "
},
"values": []
}
]
}

Search for Media Assets

The following REST call is for searching media assets. In this example the search looks for the string "private00" as a part of the file name of the media asset. You can find more details for the 'mediaQuery' paramters here:REST List API for MediaAssetFile entity

The result id of listed media assets starts always with a 'D', do not use the id starting with a number.

Request - GET

GET - http://host:1511/rest/V1.0/list/MediaAssetFile/bySearch?mediaQuery=FILEName contain " private00 "&fields=MediaAssetFile.Identifier,MediaAssetFileAttribute.Filename

Response

{
"cacheId": "20160129_111746_0",
"entityIdentifier": "MediaAssetFile",
"totalSize": 4,
"startIndex": 0,
"pageSize": 100,
"rowCount": 4,
"columnCount": 0,
"columns": [],
"rows": [
{
"object": {
"id": "9120001189316",
"label": "Media-Asset-Datei 9120001189316"
},
"values": [
" D120001189316 ",
"private00 (8).jpg"
]
},
{
"object": {
"id": "912000100164990",
"label": "Media-Asset-Datei 912000100164990"
},
"values": [
" D12000100164990 ",
"private00 (11).jpg"
]
},
{
"object": {
"id": "912000100164992",
"label": "Media-Asset-Datei 912000100164992"
},
"values": [
" D12000100164992 ",
"private00 (2).jpg"
]
},
{
"object": {
"id": "912000100164993",
"label": "Media-Asset-Datei 912000100164993"
},
"values": [
" D12000100164993 ",
"private00 (5).jpg"
]
}
]
}

Search for assignment of Media Asset to an Item (to get the missing Type)

If your current language is another than German, then you have to replace language names with the names in current language. Given in this example is 'Englisch'.

Request - GET

GET - http://host:1511/rest/V1.0/list/MediaAsset/bySearch?query=MediaAssetDocument.Identifier(Englisch,originalimage) equals " D12000100164993 "&fields=MediaAsset.Type,MediaAssetDocument.Identifier( Englisch , originalimage )

Response

{
"cacheId": "20160127_150304_0",
"entityIdentifier": "MediaAsset",
"totalSize": 1,
"startIndex": 0,
"pageSize": 100,
"rowCount": 1,
"columnCount": 0,
"columns": [],
"rows": [
{
"object": {
"id": " 1413 ",
"label": "testfdhgoeiu"
},
"values": [
" Datenblatt ",
" D12000100164993 "
]
}
]
}