Confluence page with dynamic content only refreshes in browser, not when queried via API

Jan van der Watt
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 15, 2024

I have a few pages that combine and process other Confluence pages using some or all of:

* Table Transformer

* Page Properties report

* Table Excerpt Include

I find that when I make manual data entry updates to the source of those tools, the calculated content is only refreshed when the page containing the calculations is viewed in a web browser.

I.e., if I make updates on the source pages, and use the REST API to query the calculated page from a script (e.g. https://confluence.XYZ/rest/api/content/760043385?expand=body.export_view) the content is not up to date. It also does not update if this request is made in a browser.

I've also tried fetching the calculated page from the script as if I were a browser, e.g. https://confluence.XYZ/pages/viewpage.action?pageId=754347379, and passing [NoCache = true] in the header. Still no luck.

As soon as I visit the page in a browser (or hit F5 to refresh it), the API query returns updated data.

Is this behaviour as expected, or is there something I am not doing that will make the API content as fresh as the browser's content?

The C# code looks something like this:

using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", personalAccessToken);
client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue{NoCache = true};
var pageUrl = confluenceRestApiBaseUrl + pageId;
if (!String.IsNullOrEmpty(parameters))
{
pageUrl += "?" + parameters;
}
var response = await client.GetAsync(pageUrl);
response.EnsureSuccessStatusCode();

var json = await response.Content.ReadAsStringAsync();
}

1 answer

1 accepted

3 votes
Answer accepted
Stiltsoft support
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 19, 2024

Hi @Jan van der Watt ,

The behavior is an expected one: the updates should be rendered in a browser. You may try to create a script that may automatically open your browser and refresh the required page.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events