Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Confluence Page through API however it throw error "...http://confluence.xhtml.api.link/"

Tu Ho
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 23, 2024

I'm a newbie with confluence.

Currently, I want to create a confluence page through API. My page will include page tree macro. However when i set @home/@self and another into the value, it always throw error as above:

"message": "java.lang.ClassCastException: class java.lang.String cannot be cast to class com.atlassian.confluence.xhtml.api.Link (java.lang.String is in module java.base of loader 'bootstrap'; com.atlassian.confluence.xhtml.api.Link is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @7d97cbc6)"
My request body as below:
{
                "value": "<ac:structured-macro ac:name=\"pagetree\"><ac:parameter ac:name=\"reverse\">false</ac:parameter><ac:parameter ac:name=\"sort\">natural</ac:parameter><ac:parameter ac:name=\"root\"> @home</ac:parameter><ac:parameter ac:name=\"startDepth\">3</ac:parameter><ac:parameter ac:name=\"excerpt\">true</ac:parameter><ac:parameter ac:name=\"searchBox\">false</ac:parameter><ac:parameter ac:name=\"expandCollapseAll\">false</ac:parameter></ac:structured-macro>",
                "representation":"storage"
            }
Please help me resolve this issue.
Thanks,

1 answer

0 votes
Humashankar VJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2024

Hi @Tu Ho 

 

Hi - I hope that you are Doing good !!

This is all about - the ClassCastException error

Kindly replace @home with the appropriate page title if you intend to link to a different page

It seems like the error is occurring due to the formatting of the root parameter in the page tree macro.

The @home and @self values should not have spaces before them.
Additionally, you need to provide the correct type for the root parameter, which is a link to the page

@home is wrapped with <ri:page ri:content-title=\"@home\"/>, indicating a link to the homepage.
There are no spaces before @home.
The representation remains 'storage' as it targets that the content is provided in Confluence Storage Format.

Referenced and researched a few from other communities

Hope this helps and happy to assist further !!

Thank you very much and have a fantastic day!
Warm regards

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.7.2
TAGS
AUG Leaders

Atlassian Community Events