Reputation: 3
I'm writing a simple exporting tool for a client running Kentico 13 using its REST API. My goal is to ultimately import all the content into Wordpress.
I'm able to get a large JSON with information about all the objects by doing:
curl -u USERNAME:PASSWORD -X GET https://mykentico.site/xp-admin/rest/content/currentsite/en-us/all?format=json
Then I'm parsing every object in that file by querying individual AliasPaths, to get more detailed information about each object (title, category, content, etc.) like this for example:
curl -u USERNAME:PASSWORD -X GET https://mykentico.site/xp-admin/rest/content/currentsite/en-us/document/News-Overview/June-2024/Hello-World?format=json
However the JSON I'm getting back from that last request does not contain any "permalink", "canonical URL", or any other field (that I see) that I can use to deduce the actual frontend permalink of the (page) object. This is a problem, as the actual permalink for that last page is typically something like:
https://mykentico.site/newsletter/june-2024/hello-foobar-world
i.e. the permalink folders, as well as the actual page name, have different names than the AliasPath folders and document name.
Since I will need to map the old Kentico URLs with the new Wordpress URLs, I need to be able to query the REST API and record the permalink of each individual Kentico page.
Can someone please help? Thank you.
I tried perusing the Kentico REST API at length, trying to understand how I can get this individual page permalink information from the REST API. To no avail.
Upvotes: 0
Views: 59
Reputation: 21
In Kentico 13, the "AliasPath" or "DocumentUrlPath" fields in the content tree often don't directly correspond to the final frontend URL (permalink) due to routing configurations, custom URL patterns, or rewrite rules that might be applied.
Unfortunately, the Kentico REST API may not provide the exact "frontend" URL in the direct response. However, you can try the following approaches to extract or deduce the correct URLs:
NodeAliasPath
and DocumentUrlPath
NodeAliasPath
or DocumentUrlPath
. These fields represent the path from the root of the site but may not exactly match the frontend URL./rest/content/currentsite/en-us/document/News-Overview/June-2024/Hello-World
should return these properties, but the final URL might depend on routing rules.If the REST API does not expose the canonical URL directly, you may need to:
var page = DocumentHelper.GetDocuments()
.Path("/News-Overview/June-2024/Hello-World")
.OnSite("currentsite")
.FirstObject();
var url = URLHelper.GetAbsoluteUrl(DocumentURLProvider.GetUrl(page));
Kentico's built-in URL resolving module may provide the necessary URL if configured to expose friendly URLs.
Suppose none of the methods provide direct permalinks via the API. In that case, you may need to manually map the AliasPath
to the correct permalink structure by mimicking the routing logic used in Kentico.
To summarize, check if the DocumentUrlPath
field exists in the API response or consider writing a small module using the Kentico internal API to resolve canonical URLs. This would ensure you get the exact frontend URLs for WordPress migration.
Upvotes: 0
Reputation: 995
The links to the pages are generated dynamically on the front end side. So, these data are not stored anywhere in the DB. Then, it depends whether you are using custom or content tree based routing (https://docs.kentico.com/13/developing-websites/implementing-routing)
Upvotes: 0