Chart extension do not display after updating page content through rest api

Thanh Lam December 26, 2024

I am using python to format data point into a Confluence storage format and update the page through REST API. The request did go through and it updated the table content but the chart is not displaying. 

I am getting this message from the update confluence page: 

 

                No data to display

We can’t find this chart’s source table on the page.

 

When I go to editing mode, the chart display correctly, and the Update button show  up even though I did not make any editing after sending the update request. I update the page and now the page is update. What is causing this issue? and how can I fix this? 

Please help

Thanks,

 

 

 

 

4 answers

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.
January 22, 2025

Hi @Thanh Lam - In some cases specific content or properties may handled differently by system, so i recommend logging a support ticket with Atlassian to get their opinion.

Atlassian Support

Best Regards

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.
January 20, 2025

.

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.
January 20, 2025

@Thanh Lam - Thanks for confirming, hopefully you can also ensure all the tags closed correctly with the required parameters. Atlassian Document Format

The incomplete structure may be contributing to the issues with chart rendering after API updates.

Regards

Thanh Lam January 20, 2025

@Humashankar VJ - I double checked, and all the tags closed properly. 

Like Humashankar VJ likes this
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.
January 20, 2025

Thanks @Thanh Lam for confirming.

Let me take some time to analyze what other options would have causing the issue. Will keep you posted.

Regards

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.
December 26, 2024

Hi @Thanh Lam 

Looks like it is due to how the macro processes its source table.

It may due to its dynamic binding to a data source, such as a table, in the Confluence storage format. When updating the page content via the REST API, the macro may not properly reprocess the data source until a manual update is triggered in the editor.

You can give a try by programmatically trigger a page re-render after updating the page through the REST API. This can be achieved by using one of two approaches: updating the page twice with minor modifications to trigger a re-render, or simulating the behavior of editing and saving the page using the Confluence API, which involves retrieving the page content, updating it as needed, and updating the page properties to trigger a full re-render.

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Thanh Lam December 26, 2024

Hi VJ,

I did try the method of getting back the body storage of the updated page, append new content under the old content and update it again. The new content did show up but the chart still not render. Not sure what I am missing in the html content. 

Like Humashankar VJ likes this
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.
December 27, 2024

Hi @Thanh Lam 

First, ensure that the HTML structure of your table is correct and sticks to Confluence's storage format requirements.

Also, verify that the chart macro is configured correctly and is pointing to the right data source.

Besides, confirm that you are incrementing the version number in your API request, as this is crucial for Confluence to recognize your update as a new version. If possible, consider moving your data table to a separate page and using the Page Include macro to reference it in your chart page.

You can also try using a simplified version of your table with static data to see if it renders correctly.

Best Regards

Thanh Lam December 30, 2024

Hi @Humashankar VJ ,

I created the table and chart manually on a separated page and get the body storage of that page to compare with the HTML structure that I generated from my script. The output look identical and the weird thing is that I even try to use to html that I got from the manual to update on a new page, it still not render. I am trying to use the chart plotting by confluence instead of chart macro (the look is better). As for the version number, I do update it every time i update the page.   

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.
December 31, 2024

Hi @Thanh Lam 

Your approach to troubleshooting the issue by comparing manually created content with script-generated HTML is a good starting point.

But, the fact that even manually created HTML doesn't render the chart when updated via the API suggests that the issue goes beyond content structure.

To further investigate, consider examining the API request structure to ensure it includes all necessary fields, particularly the representation parameter. Additionally, try the double update method by updating the page twice in quick succession, first with the chart content and then with a minor change.

Best Regards

Thanh Lam January 6, 2025

Hi @Humashankar VJ ,

Here is my API request structure, 

def update_conf_page_content(self, page_id: str, page_title: str, page_content: str) -> None:
"""
Function to update confluence page content by page ID
"""
url = f'{self.conf_base_url}/pages/{page_id}'
version = self.get_conf_page_version(page_id)
updated_version = version + 1

data = json.dumps({
'id': page_id,
"status": "current",
'title': page_title,
'body': {
'representation':'storage',
'value': page_content
},
'version': {
'number': updated_version
}
})

I has been trying to update it twice to thrice as you suggested but no luck. 

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.
January 6, 2025

Thanks for the update, let me research some from my end on this and will get back to you.

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.
January 10, 2025

Hi @Thanh Lam 

Looks your API Structure is all good.

I recommend checking the page_content includes both the table and the chart macro, and that the macro references the correct table, also that the ac:structured-macro block is defined correctly it may also give some issues.

Best Regards

Thanh Lam January 14, 2025

Hi @Humashankar VJ ,

My scripted html structure does not have ac:structured-macro tag because I am trying to implement to default chart of confluence rather than using it macro. Here is the short capture from my scripted html that I try to update to confluence page. 

<ac:adf-extension>
    <ac:adf-node type="extension">
        <ac:adf-attribute key="extension-key">
             chart:default
        </ac:adf-attribute>
        <ac:adf-attribute key="extension-type">
            com.atlassian.chart
        </ac:adf-attribute>
        <ac:adf-attribute key="parameters">
             <ac:adf-parameter key="chart-type">
                   LINE

You can get something similar if you chart your data from the option that appear on the table that you created on confluence page. 

 

Like Humashankar VJ likes this
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.
January 14, 2025

Thanks for the insight, let me deep dive on this and will get back to you.

Regards

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.
January 18, 2025

Hi @Thanh Lam 

Can you confirm your ADF extension status? This will help out to get problem statement moving.

Regards

Thanh Lam January 20, 2025

Hi @Humashankar VJ ,

How do check I the ADF extension status? or where do I look for find this?

 

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.
January 20, 2025

Hi @Thanh Lam 

To determine the format of a page, send a GET request to the Confluence REST API. The response will indicate whether the page is stored in the Atlas Document Format (ADF) or the legacy storage format.

GET https://your-instance.atlassian.net/wiki/rest/api/content/{contentId}?expand=body.atlas_doc_format

Regards

Thanh Lam January 20, 2025

Hi @Humashankar VJ

It stored as Atlas Document Format

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events