Hello.
I continue working on migrating my knowledge base from another platform that uses categories as a way to organize the information.
Basically, the categories are “folders” and the equivalent to those are XWiki’s Nested Pages / Nested Spaces.
I’m having trouble getting the pages to actually go to the parent pages, I’m using the REST API to achieve that, but I am unable to define the parent of a page.
Another issue I’m having is that the pages created via the API are all created as “Terminal” pages, which also adds to the issue I’m having trying to make sub-pages. Is there any way to force pages created via the API to not be “terminal”?
I read the REST API docs and apparently what I’m doing here:
form_token = fetch_csrf_token(xwiki_url, username, password)
# Set up headers for form-urlencoded data
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"XWiki-Form-Token": form_token,
"X-Requested-With": "XMLHttpRequest"
}
encoded_title = urllib.parse.quote(page_name+".WebHome")
# Prepare payload with title and content
payload = {
'title': page_name,
'parent': urllib.parse.quote('Page creation request.Brief\: How are PUNCHED panels designed and fabricated?.WebHome'),
'content': content
}
# Construct the URL for the XWiki REST API
page_url = f"{xwiki_url}/rest/wikis/xwiki/spaces/{space}/pages/{encoded_title}"
# Send the PUT request
response = session.put(page_url, headers=headers, data=payload)
Under the “page_url” variable, I should expand the “spaces/{space}” to include all the levels of nesting I’m trying to achieve?
So, for example if I want to do
Main/sub1/sub2/page02
I should have the page_url programatically be
(…)/wikis/spaces/Main/spaces/sub1/spaces/sub2/pages/page01
?
Thanks in advance, let me know if something is unclear.
Bests,