Currently I have an HTML button macro that makes a POST request with Fetch to create a new child page. The issue is that I have to delete the child page each time before creating it again. I would like to be able to check if the child page already exists (by page title I suppose) and to either make a PUT request to update the page with new information or to just DELETE it and create a new page.
Below is my pageExists function, the issue is that I’m not able to see the child pages in the response. The idea is to loop through the child pages and find a single child page which has a certain title, if that page exists then return true, if not return false.
let pageExists = function (parentId) {
let myUrl = `http://svapptest:8090/confluence/rest/api/content/${parentId}/child`
fetch(myUrl, {
method: 'GET',
headers: {
'Accept': 'application/json'
}
}).then(response => response.json())
.then(data => console.log(data))
}
Right now the response I get is:
I also get this response when adding /descendant in place of /child to the end of the URL.