Add an Asset to a Collection

post

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

Add the specified digital asset to the specified collection. If the asset being added is not a digital asset, an error is returned.

Request

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

Globally unique identifier (GUID) for the collection.

fileId
Type: string
Required: true

Globally unique identifier (GUID) of the asset to be added to the collection.

Response

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

The request was fulfilled.

Body
Root Schema : CollectionAddSingleFileResponse
Example application/json

{
    "errorCode":"0",
    "id":"F072ECEAE8DFE10499D8C160T0000DEFAULT00000000",
    "itemID":"DDEA5A0845C4628E6DAAE369T0000DEFAULT00000000",
    "type":"collection"
}
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 one asset to a collection.

POST .../collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files/D76EE391B7B098777666CBFF45B3E9DD649055F5640B

Request Header

None.

Request Body

None.

HTTP Status Code

HTTP_STATUS = 200

JSON Response

{
    "errorCode": "0",
    "id": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "itemID": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B",
    "type": "collection"
}

Example 2

The following example attempts to re-add the same asset previously added to a collection.

POST .../collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files/D76EE391B7B098777666CBFF45B3E9DD649055F5640B

Request Header

None.

Request Body

None.

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",
    "itemID": "D76EE391B7B098777666CBFF45B3E9DD649055F5640B",
    "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 doesn’t add the item to the collection because either the collection or the item does not exist.

POST ...collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files/DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471

Request Header

None.

Request Body

None.

HTTP Status Code

HTTP_STATUS = 400

JSON Response

{
    "errorCode": "-32",
    "errorKey": "!$!csUnprivilegedSystemError",
    "errorMessage": "The error was caused by an internally generated issue. The error has been logged.",
    "errorType": "collection",
    "id": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "itemID": "DC1C4D02CC1CD75E8597CB9245B3E9DD649052373471",
    "title": "The error was caused by an internally generated issue. The error has been logged.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

Example 4

The following example doesn’t add the item to the collection because the item is not shared with or owned by the user.

POST ...collections/F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B/files/DA02F6D6C48C5C68B65D43C345B3E9DD649052373471

Request Header

None.

Request Body

None.

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": "F5E88D06A5AEC588BDB96A2045B3E9DD649055F5640B",
    "itemID": "DA02F6D6C48C5C68B65D43C345B3E9DD649052373471",
    "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 5

The following example doesn’t add the item to the collection because the asset being added is not a digital asset.

POST ../collections/FE8F509271707ED7E032109345B3E9DD6490C90F25A1/files/D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1  

Request Header

None.

Request Body

None.

HTTP Status Code

HTTP_STATUS = 400

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",
    "itemID": "D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1",
    "title": "Item fFileGUID:D216B4F1A638996B0764DE1145B3E9DD6490C90F25A1 is not allowed to be added to collection fFolderGUID:FE8F509271707ED7E032109345B3E9DD6490C90F25A1.",
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}