Hierarchical items operations

Overview

Hierarchical items are Blog posts, List items, and hierarchical dynamic items.
Blog posts are part of the Blogs module and List items are part of the Lists module.

Get data for the parent module

Getting the data of a parent module of a child type, for example - Blogs or Lists, is the same as getting data for any other module.

To do this, you must execute a GET request to the following endpoint:

{baseurl}/api/default/{entity}

Where {entity} is the entity of the module that you are working with.

Sample request

GET http://mysite.com/api/default/blogs

Sample response

Filter items by ParentId

If the request is made for the child type only with the entity of that type, then all items for that type will be returned, regardless of their parent.

To get all child items for a specific parent, you should apply a filter by the ParentId property and execute a GET request to the following endpoint:

{baseurl}/api/default/{entity}?$filter=(ParentId eq {parentItemId})

Where:

  • {entity} is the entity of the child module that you are working with
  • {parentItemId} is the ID of the parent item

Sample request

GET http://mysite.com/api/default/blogposts?$filter=(ParentId eq d17f777f-6350-411d-83b1-1d0c5e93996b)

Sample response

Create an item with ParentId

To create a hierarchical item, you must execute a POST request to the entity endpoint and specify the item properties in JSON format inside the request body. The ParentId property indicates under which parent you want to create a hierarchical child item.

To create a hierarchical item, execute a POST request to the following endpoint:

{baseurl}/api/default/{entity}

Where {entity} is the entity of the module that you are working with.

You must specify the properties of the item that you want to create in JSON format inside the request body.

Sample request

POST http://mysite.com/api/default/blogposts

Sample response

Update an item with ParentId

To update a hierarchical item, you must execute a PATCH request to the entity endpoint and specify the item’s properties that you want to modify in JSON format inside the request body.
The ParentId property is not important in this type of action, because you use the itemId itself.

To update a child item, you must execute a POST request to the following endpoint:

{baseurl}/api/default/{entity}({itemId})

Where:

  • {entity} is the entity of the module that you are working with
  • {itemId} is the ID of the item that you want to modify

You must specify all properties that you want to modify in JSON format inside the request body.

Sample request

PATCH http://mysite.com/api/default/blogposts(97d57528-d9e9-4784-8689-f2e635b721e0)

Sample response

No response body

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?