Work with content
The samples in this section use Sitefinity CMS News items. The samples focus on the
data function of the
sitefinity object that returns a
data object. The
data object is the mechanism that enables Sitefinity JS SDK to work with the OData services.
In the following samples, the
dataOptions object specifies which content item to query.
It has the following properties:
urlName – which content item to query
providerName – which data provider is the content item from
cultureName – which language version of the content item you want to query
As a result, you get the
data object and you can call its various functions, such as:
These functions accept an object, which has the following functions and properties:
NOTE: There is a limitation in the OData web services that limits the maximum items in a query to 50. To change this limit in Sitefinity CMS backend, navigate to Administration » Settings » Advanced » WebServices » Routes » Frontend » Services » <your service> » <content type>. Change the value of Default page size field.
Query a collection of News items
The following sample demonstrates how to query multiple news items, by using the get function of the
Query a single News item
The following sample demonstrates how to query a single news item, by using the
getSingle function of the
Create a News item
The following sample demonstrates how to create a News item, by using the
create function of the
Update a News item
The following sample demonstrates how to update a News item, by using the
update function of the
Delete a News item
The following sample demonstrates how to delete a News item, by using the
destroy function of the
A media item upload request requires you to send headers with the request.
This sample demonstrates how to upload an image in JPEG format. Therefore, you must send the following headers with the request:
The following sample sends three requests in a batch request to Sitefinity CMS:
- The first is a
POST request to upload the binary data
- The second is a
PATCH request to update the metadata of the image
- The third is a
POST request to specify the album where the image must be uploaded. All three requests are handled by the
data object's upload function.
NOTE: This sample assumes that there is an
<input type="file" name="photo" id="photo"> element present in your application.