Add a List of Assets to a Collection

post

/documents/api/1.1/collections/{collectionId}/files

Adds the list of assets to the specified collection. If the asset being added is not a digital asset, an error is returned. By default, if an asset is already in the collection, an error is returned. The optional skipDuplicate parameter can be used to get extended information about each asset ID listed.

.

Request

Supported Media Types
  • application/json
  • application/xml
Path Parameters
collectionId
Type: string
Required: true

Globally unique identifier (GUID) for the collection.

Body Parameter
The request body defines details on assets to be added to the collection. Bold indicates a required value.
Root Schema : AddMultipleAssetsToCollectionBody
The request body defines details on assets to be added to the collection. Bold indicates a required value.

Response

Supported Media Types
  • application/json
  • application/xml
200 Response

The request was fulfilled.

Body

The items array is returned only if the optional parameter is used.

Root Schema : CollectionAddDeleteMultipleFilesResponse

The items array is returned only if the optional parameter is used.

Nested Schema : items
Type: array
List of file IDs that were acted on.
Nested Schema : ItemsAddedOrRemovedFromCollection
Example application/json

{
    "count":"3",
    "errorCode":"0",
    "id":"FB0CC049082D12D32B3A8774T0000DEFAULT00000000",
    "idList":"DDEA5A0845C4628E6DAAE369T0000DEFAULT00000000,DD65472E2B67302C13474B5BT0000DEFAULT00000000,DDBCE14AECFED0D255373924T0000",
    "type":"collection",
    "items":[
        {
            "type":"file",
            "id":"DDEA5A0845C4628E6DAAE369T0000DEFAULT00000000",
            "timeStamp":"{ts '2017-04-04 12:45:52.084'}"
        },
        {
            "type":"file",
            "id":"DD65472E2B67302C13474B5BT0000DEFAULT00000000",
            "timeStamp":"{ts '2017-04-04 12:45:52.097'}"
        },
        {
            "type":"file",
            "id":"DDBCE14AECFED0D255373924T0000DEFAULT00000000",
            "message":"!csDAMItemAlreadyInCollection,fFileGUID:DDBCE14AECFED0D255373924T0000DEFAULT00000000,fFolderGUID:FB0CC049082D12D32B3A8774T0000DEFAULT00000000",
            "timeStamp":"{ts '2017-04-04 12:45:52.110'}"
        }
    ]
}
400 Response

The asset being added is not a digital asset, or request parameters are not formatted correctly.

403 Response

User does not have rights to the specified collection or asset.

404 Response

Collection is in the trash or is not found.

Examples

The following example adds 3 assets to a collection.

POST .../collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files

Request Header

None.

Request Body

{
	"idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B"
}

HTTP Status Code

HTTP_STATUS = 200

JSON Response

{
    "errorCode": "0",
    "id": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B",
    "type": "collection"
}

Example 2

The following example adds 3 assets to a collection. By default, an error is returned if any of the assets are already in the collection.

POST .../collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files

Request Header

None.

Request Body

{
	"idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B"
}

HTTP Status Code

HTTP_STATUS = 400

JSON Response

{
    "errorCode": "-96",
    "errorKey": "!csDAMItemAlreadyInCollection,fFileGUID:D76EE391B7B098777666CBFF45B3E9DD649055F5640B,fFolderGUID:F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "errorMessage": "Item fFileGUID:D76EE391B7B098777666CBFF45B3E9DD649055F5640B is already a member of collection fFolderGUID:F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B.",
    "errorType": "collection",
    "id": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B",
    "title": "Item fFileGUID:D76EE391B7B098777666CBFF45B3E9DD649055F5640B is already a member of collection fFolderGUID:F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

Example 3

The following example adds 3 assets to a collection, with 1 of the 3 assets already in the collection. With the skipDuplicate=1 parameter, the response includes an items array. If an item in the array does not have a 'message' value, the item was added to the collection. If the item has a 'message' value, it indicates why the item was not added to the collection.

POST .../collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files

Request Header

None.

Request Body

{
	"idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B"
	"skipDuplicate": "1"
}

HTTP Status Code

HTTP_STATUS = 200

JSON Response

{
    "count": "3",
    "errorCode": "0",
    "id": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "idList": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B,DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B,DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B",
    "type": "collection",
    "items": [
        {
            "type": "file",
            "id": "DBC670E5F422C0C4E2A0A03845B3E9DD649055F5640B",
            "timeStamp": "{ts '2017-05-16 22:16:44.679'}"
        },
        {
            "type": "file",
            "id": "DD5294D6C01505D8AE9BB57445B3E9DD649055F5640B",
            "timeStamp": "{ts '2017-05-16 22:16:44.945'}"
        },
        {
            "type": "file",
            "id": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B",
            "message": "!csDAMItemAlreadyInCollection,fFileGUID:D76EE391B7B098777666CBFF45B3E9DD649055F5640B,fFolderGUID:F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
            "timeStamp": "{ts '2017-05-16 22:16:44.519'}"
        }
    ]
}

Example 4

The following example doesn’t add the item to the collection because the idList parameter is missing. The same response is returned if the parameter is empty.

POST ...collections/F83479E04F3A2B1DDC7ED49D45B3E9DD649052373471/files

Request Header

None.

Request Body

{
	"skipDuplicate" : "1"
}

HTTP Status Code

HTTP_STATUS = 400

JSON Response

{
    "errorCode": "-97",
    "errorKey": "!csDAMOneOfRequiredFieldsMissing,item\\,items",
    "errorMessage": "One of the required fields item,items is missing.",
    "errorType": "collection",
    "id": "F83479E04F3A2B1DDC7ED49D45B3E9DD649052373471",
    "title": "One of the required fields item,items is missing.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

Example 5

In the following example, no items are added to the collection because one or more of the items listed are not owned by or shared with the user.

POST ..collections/F83479E04F3A2B1DDC7ED49D45B3E9DD649052373471/files

Request Header

None.

Request Body

{
	"idList": "DA02F6D6C48C5C68B65D43C345B3E9DD649052373471,DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471"
	"skipDuplicate": "1"
}

HTTP Status Code

HTTP_STATUS = 403

JSON Response

{
    "errorCode": "-20",
    "errorKey": "!csCloudItemInsufficientPrivileges,UserAA,fFileGUID:DA02F6D6C48C5C68B65D43C345B3E9DD649052373471,ADD_ITEM_TO_COLLECTION",
    "errorMessage": "User 'UserAA' has insufficient privilege to access fFileGUID:DA02F6D6C48C5C68B65D43C345B3E9DD649052373471 with service ADD_ITEM_TO_COLLECTION.",
    "errorType": "collection",
    "id": "F83479E04F3A2B1DDC7ED49D45B3E9DD649052373471",
    "idList": "DA02F6D6C48C5C68B65D43C345B3E9DD649052373471,DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471",
    "skipDuplicate": "1",
    "title": "User 'UserAA' has insufficient privilege to access fFileGUID:DA02F6D6C48C5C68B65D43C345B3E9DD649052373471 with service ADD_ITEM_TO_COLLECTION.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

Example 6

In the following example, no items are added to the collection because the collection is not owned by or shared with the user.

POST  ..collections/F5D88A8F6F68BB240E3826DA45B3E9DD649052373471/files

Request Header

None.

Request Body

{
	"idList": "DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471"
	"skipDuplicate": "1"
}

HTTP Status Code

HTTP_STATUS = 403

JSON Response

{
    "errorCode": "-20",
    "errorKey": "!csCloudItemInsufficientPrivileges,UserAA,fFolderGUID:F5D88A8F6F68BB240E3826DA45B3E9DD649052373471,ADD_ITEM_TO_COLLECTION",
    "errorMessage": "User 'UserAA' has insufficient privilege to access fFolderGUID:F5D88A8F6F68BB240E3826DA45B3E9DD649052373471 with service ADD_ITEM_TO_COLLECTION.",
    "errorType": "collection",
    "id": "F5D88A8F6F68BB240E3826DA45B3E9DD649052373471",
    "idList": "DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471",
    "skipDuplicate": "1",
    "title": "User 'UserAA' has insufficient privilege to access fFolderGUID:F5D88A8F6F68BB240E3826DA45B3E9DD649052373471 with service ADD_ITEM_TO_COLLECTION.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

Example 7

The following example doesn’t add any items to the collection because one of the assets being added is not a digital asset.

POST ../collections/FE8F509271707ED7E032109345B3E9DD6490C90F25A1/files/

Request Header

None.

Request Body

{
     "idList": "D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1,D513117E63E0C02AE95DFF5245B3E9DD6490C90F25A1"
}

HTTP Status Code

HTTP_STATUS = 400

JSON Response

JSON Response
{
    "errorCode": "-96",
    "errorKey": "!csDAMItemNotAllowedInCollection,fFileGUID:D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1,fFolderGUID:FE8F509271707ED7E032109345B3E9DD6490C90F25A1",
    "errorMessage": "Item fFileGUID:D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1 is not allowed to be added to collection fFolderGUID:FE8F509271707ED7E032109345B3E9DD6490C90F25A1.",
    "errorType": "collection",
    "id": "FE8F509271707ED7E032109345B3E9DD6490C90F25A1",
    "idList": "D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1,D513117E63E0C02AE95DFF5245B3E9DD6490C90F25A1",
    "title": "Item fFileGUID:D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1 is not allowed to be added to collection fFolderGUID:FE8F509271707ED7E032109345B3E9DD6490C90F25A1.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"