CRUD Operations

To perform CRUD operations via the web services you work with the endpoint for the desired content.

Get the available content types (entity sets) exposed by the OData services

Request type: GET

Format: {{baseurl}}/api/default

The call to the service root returns all available content types (entities) you can work with via the OData web services

Read the service metadata

Request type: GET

Format: {{baseurl}}/api/default/$metadata

$metadata is a Sitefinity endpoint that contains a machine-readable description of the service model including type schemas, available operations, and so on.

Get a collection of items

Request type: GET

Format: {{baseurl}}/api/default/{{entity}}

One of the most common scenarios when working with web services is to get a list of items from a specified type (entity). For example, to get a list of news items, use http://yoursite.com/api/default/newsitems.

The value property of the response contains the collection of items.

NOTE: If the @odata.nextLink annotation is present, the server opted to split the result set across multiple pages. The client can also drive paging using $top and $skip. For more information refer to the Pagination over a collection section in this article.

Get an item by Id

Request type: GET

Format: {{baseurl}}/api/default/{{entity}}({{item_id}})

To get an item, using its Id, specify the entity this item belongs to, and append an id segment enclosed in brackets

Get images from a specific album

Request type: GET

Format: {{baseurl}}/api/default/images?$filter=ParentId eq {{image_library_id}}

To get images from a specified album, query the images entity URL and filter by the ParentIdfield, specifying the Id of the album.

Get blog posts for a specific blog

Request type: GET

Format: {{baseurl}}/api/default/blogposts?$filter=ParentId eq {{blog_id}}

You can filter hierarchical content using the ParentId field. For instance, to get the blog posts created for a given blog, pass the blog Id to the filter by ParentId

Create an item

Request type: POST

Format: {{baseurl}}/api/default/{{entity}}

To create an item, send a POST request to the entity endpoint, and specify the item properties in JSON format inside the request body. For example: {Title: Sample news item}. The request format can be viewed on the service /sfhelp web page. Authorization header with a token is usually required for those requests.

NOTE: Setting the PublicationDate and ExpirationDate fields is not supported when using the OData web services. This is part of the item scheduling functionality, which is not exposed through the OData services.

Create a taxon

Request type: POST

Format: {{baseurl}}/api/default/{{entity}}

To create a taxon for any taxonomy you must send a POST request to the taxonomy entity url. In the body include the title of the new taxon and the id of the taxonomy. For example, to create a new tag you must specify http://mysite.com /api/default/flat-taxa and pass the following JSON in the body:

{

  "Title": "latest news",

  "TaxonomyId": "{{taxonomy_id}}",

  "Name": "latest-news"

}

Specify taxa when creating a new item

Request type: POST

Format: {{baseurl}}/api/default/{{entity}}

To create a new item and classify it with a taxon, send a POST request to the entity url, and in the body of the request pass the classification field name and the Id of the taxon you want to classify the item with. For example, to create a news item and classify it with a tag you must send a POST to: https://mysite.com/api/default/news and in the body of the request have a JSON similar to:

{

  "Title": "Sample news item created with taxon",

  "Tags": ["{{taxon_id}}"]

}

The request format can be viewed on the service /sfhelp web page. Authorization header with a token is usually required for those requests.

Create an image

Request type: POST

Format: {{baseurl}}/api/default/images

To create media content, send a POST request to the images entity URL, and add the image binary to the body of the request. Add an X-Sf-Properties header to specify the Id of the image library where you want to create the image, for example: {ParentId:"{{image_library_id}}"}

Upload a different image for a specific culture

Request type: PATCH

Format: {{baseurl}}/api/default/images({{image_id}})?sf_culture=de

To add different image for a specific language culture, you must make a PATCH request to the images entity URL, pass the Id of the image you want to update, and append a ?sf_culture={{your culture}} parameter to specify for which culture you’ll be making the update. Pass the image binary data in the body of the request

Update an item

Request type: PATCH

Format: {{baseurl}}/api/default/{{entity}}({{item_id}})

To update an item, send a PATCH request with the properties you wish to modify. Authorization header with a token is usually required for those requests.

Delete an item

Request type: DELETE

Format: {{baseurl}}/api/default/{{entity}}({{item_id}})

To delete an item, send an HTTP DELETE to the resource URL. Authorization header with a token is usually required for those requests.


Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?