Untitled
unknown
plain_text
2 years ago
2.1 kB
14
Indexable
<!DOCTYPE html>
<html>
<head>
<title>Confluence Page Data Fetch</title>
</head>
<body>
<div id="confluenceData"></div>
<script>
// Replace with your Confluence URL and page ID
const confluenceBaseUrl = 'https://your-confluence-instance.atlassian.net';
const sourcePageId = '12345'; // Replace with your source page ID
const targetPageId = '67890'; // Replace with your target page ID
const url = `${confluenceBaseUrl}/wiki/rest/api/content/${sourcePageId}?expand=body.storage`;
fetch(url, {
method: 'GET',
})
.then(response => response.json())
.then(data => {
const content = data.body.storage.value;
const targetElement = document.getElementById('confluenceData');
targetElement.innerHTML = content;
// Optionally, you can save this content to another page.
const updateUrl = `${confluenceBaseUrl}/wiki/rest/api/content/${targetPageId}`;
fetch(updateUrl, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
version: {
number: data.version.number + 1
},
title: data.title,
type: data.type,
body: {
storage: {
value: content,
representation: 'storage'
}
}
})
})
.then(response => response.json())
.then(result => {
console.log('Data saved to target page:', result);
})
.catch(error => {
console.error('Error updating target page:', error);
});
})
.catch(error => {
console.error('Error fetching data from source page:', error);
});
</script>
</body>
</html>
Editor is loading...