REST API how to replace an assignment of media asset to an article
Introduction
To replace an existing assignment of media asset to an article you can use a POST REST call. At the end it is the same call which you use for a new assignment (How to create an assignment of media asset to an article using the PIM REST API). But the way to this call is different. The next two screens show 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) where the content object should be adjusted.
Before:
|
After:
|
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
assignment ID (Media Asset Document)
additional required parameter for assignment
other parameter
Modify an assignment of media asset to an article
You need some parameters before you can modify an existing assignment. These first four parameters are fix and define the assignment itself. If you modify one of these parameters you will create a new assignment or overwrite another one.
Call text |
Explanation |
others |
|
originalimage |
|
Englisch |
|
18503@1 |
|
The next two parameters are for the real modification.
Call text |
Explanation |
modified by rest call |
|
D12000100164990 |
|
Search for existing assignment
To get all this information for changing an assignment you can use this example: Search for all assignments to an Item.
And finally here is the REST call for modifying the assignment. The body of this POST is formatted in JSON.
{
"columns": [
{
"identifier": "ArticleMediaAssetDocument.Identifier(
others
,
originalimage
,
Englisch
)",
"identifier": "ArticleMediaAssetMap.Name(others)"
}
],
"rows": [
{
"object": {
"id": "
18503@1
"
},
"values": [
"
D12000100164990
"
],
"values": [
"
modified by rest call
"
]
}
]
}
{
"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 all assignments to an Item
If your current language is another than German, then you have to replace language names with the names in the currently active language. Given in this example is 'Englisch'.
GET - http://host:1511/rest/V1.0/list/Article/ArticleMediaAssetMap/byItems?items= 18503@1 &fields=ArticleMediaAssetDocument.Identifier&qualificationFilter=quality( originalimage )
{
"cacheId": "20160201_144011_0",
"entityIdentifier": "ArticleMediaAssetMap",
"totalSize": 1,
"startIndex": 0,
"pageSize": 100,
"rowCount": 1,
"columnCount": 0,
"columns": [],
"rows": [
{
"object": {
"id": "
18503@1
",
"label": "robustnessdeep0011"
},
"qualification": {
"mediaAssetType": "
Andere
",
"language": "
Englisch
",
"quality": "
originalimage
"
},
"values": [
"
D12000100164990
"
]
}
]
}