Fetching a page's attached pages using REST - Kentico 13

Mike Young asked on June 4, 2024 00:00

When getting a page using the REST API is there any way to access the data of its attached pages? We have a page type that has a page field but the REST API returns null for that field, even when there is a page populated in that field in the CMS. That field's page can be accessed server-side in MVC, it is only when calling the REST endpoints that the field returns null. All of the more standard/basic fields for stuff like text, number etc are present and populated.

Here is the URL I am attempting this with: https://EXAMPLE.COM/rest/content/currentsite/defaultculture/childrenof/?format=json&classnames=custom.marketingBanner&topn=30&selectonlypublished=true

Environment

Kentico 13 version: [13.0.118] CMS running on .NET version: [4.8] CMS Deployment environment: [Azure] Docs: https://docs.kentico.com/13/integrating-3rd-party-systems/xperience-rest-service/getting-data-using-rest

Correct Answer

Juraj Ondrus answered on June 4, 2024 09:28

I assume that by attached pages you mean the related pages. Added e.g. to a page type field "Pages". In this case the values are not stored within the page object in the DB but in the binding table CMS_Relationship (very old design). This means that you need to request the cms.relationship object type and get the values for the left or right node of the relationship. So, the REST API call could look like this:

/rest/cms.relationship?where=LeftNodeID=16

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.