Basket
To add medias in baskets, there are two ways:
- Upload, create medias and add medias in basket in batch
- Upload, create media in basket
Upload, create medias and add medias in basket in batch
⚠️ You can add maximum 500 medias at a time into a basket.
1.Upload
First, upload a file on keepeek as described in the Getting started page.
You should receive a response as:
{
"id": "{file-id}",
"expirationDate": "{date}",
"fileName": "{fiename}",
"fileContentType": "{content-type}",
"size": {fileSize},
"_links": {
"self": {
"href": "{file-url}"
}
}
}
2.Create medias
To create a media, do a POST on the /api/dam/medias with the link received in the location header during the upload part.
curl --request POST \
--url {instanceUrl}/api/dam/baskets/medias \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"_links": {
"from": {
"href": "{fileUrl}"
}
}
}'You should receive a location header as:
{instanceUrl}/api/dam/medias/{mediaId}
You can create multiple medias with multiple calls.
3.Add medias in basket
You are now able to add the medias into a basket by doing a POST request on:
{instanceUrl}/api/dam/baskets/{basketId}/medias-collection
curl --request POST \
--url {instanceUrl}/api/dam/baskets/{basketId}/medias-collection \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"ids": [
{mediaId1}, {mediaId2},...
]
}'
Add medias in basket with a link
You can also create the medias directly in the basket.
Once you had upload the media as described in the Getting started page.
You should receive a response as:
{
"id": "{file-id}",
"expirationDate": "{date}",
"fileName": "{fiename}",
"fileContentType": "{content-type}",
"size": {fileSize},
"_links": {
"self": {
"href": "{file-url}"
}
}
}To create the media directly in the basket, do a POST request on:
{instanceUrl}api/dam/baskets/{basketId}/medias
curl --request POST \
--url {instanceUrl}/api/dam/baskets/{basketId}/medias \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"_links": {
"from": {
"href": "{file-url}"
}
}
}'This creates the media directly in the basket.
Folder
First, it is currently not possible to add multiple medias to a folder at once.
Add an existing media to a folder
To add an already existing media to a folder, do a POST request on:
{instanceUrl}api/dam/baskets/{basketId}/medias
curl --request POST \
--url 'https://qualification.ci.keepeek-dev.com//api/dam/folders/640/medias' \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"id": {mediaId}
}'Create media in folder
You can also create the medias directly in the folder.
Once you had upload the media as described in the Getting started page.
You should receive a response as:
{
"id": "{file-id}",
"expirationDate": "{date}",
"fileName": "{fiename}",
"fileContentType": "{content-type}",
"size": {fileSize},
"_links": {
"self": {
"href": "{file-url}"
}
}
}To create the media directly in the basket, do a POST request on:
{instanceUrl}api/dam/folders/{folderId}/medias
curl --request POST \
--url {instanceUrl}/api/dam/folders/{folderId}/medias \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"_links": {
"from": {
"href": "{file-url}"
}
}
}'This creates the media directly in the folder.
Move medias from a folder to another one
This operation is in two parts:
- Add the media to a folder (see step above)
- Remove the media from the original folder
Remove media from the original folder
It is the same path and method as adding medias, just instead of doing a POST request, do a DELETE request.
curl --request DELETE \
--url {instanceUrl}/api/dam/folders/{folderId}/medias/{mediaId} \
--header 'authorization: Basic login:password'
Create a folder child
To create a folder, you need to first get the children of a folder by using the folder-tree path.
To get the children of a folder, use the path:
{instanceUrl}/api/dam/folder-tree/{folderId}/children
To create the folder childm do a POST request on the path {instanceUrl}/api/dam/folder-tree/{folderId}/children.
curl --request POST \
--url {instanceUrl}/api/dam/folder-tree/{folderId}/children \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"title": "title",
"descrption": "description"
}'PS: It is not possible to create directly a tree structure with the API.
Create a root folder
Do the same call, just on the folder-tree path:
curl --request POST \
--url {instanceUrl}/api/dam/folder-tree \
--header 'authorization: Basic login:password' \
--header 'content-type: application/json' \
--data '{
"title": "title",
"descrption": "description"
}'
Commentaires
0 commentaire
Vous devez vous connecter pour laisser un commentaire.