Libraries operations
Get a collection of libraries
To get all libraries, you must execute a GET request to the following endpoint:
{baseurl}/api/default/{media}
Where media is the libraries’ entity set, for example – albums or videolibraries.
Sample request
GET
http://mysite.com/api/default/videolibraries
Sample response
Status code: 200 OK
{
"@odata.context": "http://localhost:1337/api/default/$metadata#videolibraries(Id,LastModified,PublicationDate,Title,Description,DateCreated,IncludeInSitemap,UrlName,MaxSize,MaxItemSize,BlobStorageProvider,OutputCacheProfile,ClientCacheProfile,CoverId,ChildrenCount)",
"value": [
{
"Id": "d4e22033-7bcd-4ce5-9c70-41f9b83d7d66",
"LastModified": "2021-04-21T08:29:14Z",
"PublicationDate": "2021-04-21T08:29:14Z",
"Title": "Sample videos",
"Description": "",
"DateCreated": "2021-04-21T08:29:14Z",
"IncludeInSitemap": true,
"UrlName": "sample-videos",
"MaxSize": 0,
"MaxItemSize": 0,
"BlobStorageProvider": "Database",
"OutputCacheProfile": null,
"ClientCacheProfile": null,
"CoverId": null,
"ChildrenCount": 1
},
{
"Id": "2f94846a-8133-4a85-94bf-b11b1bf103e7",
"LastModified": "2021-04-21T08:32:26Z",
"PublicationDate": "2021-04-21T08:32:26Z",
"Title": "Colors",
"Description": "",
"DateCreated": "2021-04-21T08:32:26Z",
"IncludeInSitemap": true,
"UrlName": "colors",
"MaxSize": 0,
"MaxItemSize": 0,
"BlobStorageProvider": "FileSystem",
"OutputCacheProfile": null,
"ClientCacheProfile": null,
"CoverId": null,
"ChildrenCount": 0
}
]
}
This request queries all available libraries and their child folders recursively.
NOTE: If in the request you do not specify a site, a culture, or a data provider, the libraries that are queried are taken from the default data provider and default culture of the default site in the system.
Get a specific library
To get a single library, you must execute a GET request to the following endpoint:
{baseurl}/api/default/{media}({id})
Where:
mediais the library’s entity set, for example –albumsorvideolibrariesidis the ID of the library that you want to get, for example –d4e22033-7bcd-4ce5-9c70-41f9b83d7d66
Sample request
GET
http://mysite.com/api/default/videolibraries(d4e22033-7bcd-4ce5-9c70-41f9b83d7d66)
Sample response
Status code: 200 OK
{
"@odata.context": "http://localhost:1337/api/default/$metadata#videolibraries/$entity",
"Id": "d4e22033-7bcd-4ce5-9c70-41f9b83d7d66",
"LastModified": "2021-04-21T08:29:14Z",
"PublicationDate": "2021-04-21T08:29:14Z",
"Title": "Sample videos",
"Description": "",
"DateCreated": "2021-04-21T08:29:14Z",
"IncludeInSitemap": true,
"UrlName": "sample-videos",
"MaxSize": 0,
"MaxItemSize": 0,
"BlobStorageProvider": "Database",
"OutputCacheProfile": null,
"ClientCacheProfile": null,
"CoverId": null,
"ThumbnailProfiles": [
"vthumbnail"
],
"ParentId": null,
"Provider": "OpenAccessDataProvider",
"ChildrenCount": 1
}
Create a library
To create a library, you must execute a POST request to the following endpoint:
{baseurl}/api/default/{media}
Where media is the library’s entity set, for example – albums or videolibraries.
Sample request
POST
http://mysite.com/api/default/videolibraries
Request body
{
"Title": "New library",
"BlobStorageProvider": "Database",
"UrlName": "new-library"
}
Sample response
Status code: 201 Created
{
"@odata.context": "http://localhost:1337/api/default/$metadata#videolibraries/$entity",
"Id": "477045b1-56f3-4abf-8799-33d42813636f",
"LastModified": "2021-04-26T16:22:06Z",
"PublicationDate": "2021-04-26T16:22:06Z",
"Title": "New library",
"Description": "",
"DateCreated": "2021-04-26T16:22:06Z",
"IncludeInSitemap": true,
"UrlName": "new-library",
"MaxSize": 0,
"MaxItemSize": 0,
"BlobStorageProvider": "Database",
"OutputCacheProfile": null,
"ClientCacheProfile": null,
"CoverId": null,
"ThumbnailProfiles": [
"vthumbnail"
],
"ParentId": null,
"Provider": "OpenAccessDataProvider",
"ChildrenCount": 0
}
Status code: 400 Bad Request
If you make the same request as above, but you change the verb to PUT, the server responds with the following error:
{
"error": {
"code": "BadRequest",
"message": "Missing properties: Title,Description,IncludeInSitemap,Ordinal,UrlName,Author,Category,Tags,ParentId",
"target": "Telerik.Sitefinity.Web.Api"
}
}
Partially update a library
Updating a library can be done in two ways – with a PATCH or with a PUT request. The difference between the two verbs is that PATCH allows for a partial update, whereas PUT requires all fields to be present in the request’s body.
To partially update a library, you must execute a PATCH request to the following endpoint:
{baseurl}/api/default/{media}({id})
Where:
mediais the library’s entity set, for example –albumsorvideolibrariesidis the ID of the library that you want to update, for example –d4e22033-7bcd-4ce5-9c70-41f9b83d7d66
Sample request
PATCH
http://misite.com/api/default/videolibraries(d4e22033-7bcd-4ce5-9c70-41f9b83d7d66)
Request body
{
"Title":"Edited library title"
}
Sample response
Status code: 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Missing properties: Description,IncludeInSitemap,MaxSize,MaxItemSize,BlobStorageProvider,OutputCacheProfile,ClientCacheProfile,CoverId,ThumbnailProfiles",
"target": "Telerik.Sitefinity.Web.Api"
}
}
Fully update of a library
Updating a library can be done in two ways – with a PATCH or with a PUT request. The difference between the two verbs is that PATCH allows for a partial update, whereas PUT requires all fields to be present in the request’s body.
To update a library, you must execute a PUT request to the following endpoint:
{baseurl}/api/default/{media}({id})
Where:
mediais the library’s entity set, for example –albumsorvideolibrariesidis the ID of the library that you want to update, for example –d4e22033-7bcd-4ce5-9c70-41f9b83d7d66
NOTE: You can get an error, if one or more properties of the library are not included in the request’s body.
Sample request
PUT
http://mysite.com/api/default/videolibraries(d4e22033-7bcd-4ce5-9c70-41f9b83d7d66)
Request body
{
"Title":"Edited library title"
}
Sample response
Status code: 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Missing properties: Description,IncludeInSitemap,MaxSize,MaxItemSize,BlobStorageProvider,OutputCacheProfile,ClientCacheProfile,CoverId,ThumbnailProfiles",
"target": "Telerik.Sitefinity.Web.Api"
}
}
Sample request (all required properties)
PUT
http://mysite.com/api/default/videolibraries(d4e22033-7bcd-4ce5-9c70-41f9b83d7d66)
Request body
{
"Title":"Edited library title",
"Description": "A description of the library.",
"IncludeInSitemap": "False",
"MaxSize": 0,
"MaxItemSize": 0,
"BlobStorageProvider": "Database",
"OutputCacheProfile": "",
"ClientCacheProfile": "",
"ThumbnailProfiles": [],
"CoverId": null
}
Sample response
Status code: 204 No Content
No response body
Delete a library
To delete a library, you must execute a DELETE request to the following endpoint:
{baseurl}/api/default/{media}({id})
Where:
mediais the library’s entity set, for example –albumsorvideolibrariesidis the ID of the library that you want to delete, for example –d4e22033-7bcd-4ce5-9c70-41f9b83d7d66
Sample request
DELETE
http://mysite.com/api/default/videolibraries(d4e22033-7bcd-4ce5-9c70-41f9b83d7d66)
Sample response
Status code: 204 No Content
No response body