Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trying to create a new page as a child of an existing page with REST API and curl

Kelly Maurice March 21, 2024

I've seen a number of posts on this topic but they are not solving my problem. We have a corporate Jira account and I can view, create and edit confluence pages using Chrome browser and my company credentials.

I'm trying to do this same thing by using curl. I have checked and I believe Confluence Remote API is enabled. I have a fairly new version of Confluence so can use the modern form of browsing described in the docs.

I can browse the catalogs successfully using commands like (with personal account and password):

curl -D- -u user:pw-X GET -H "Content-Type: application/json" https://<company base confluence url>

I try to create the page with:

curl -u user:pw -X POST -H 'Content-Type:application/json' -d '{"type":"page","title":"testing_curl","ancestors":[{"id":1949495409}],"space":{"key":"OneMapDev"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' <company confluence base url>/rest/api/content/

I'm confused about a few things:

  1. will the basic authentication with user/pw work for page creation? (will move to API token after it works)?
  2. what is the -D- switch and why is this form of the curl command different
  3. how many ancestors to supply? I have a page's ID and want the new page to be a child of it. I give one ancestor in the ancestor's list and it is the ancestor of the parent of the page I'm trying to create
  4. I dont understand the URL that is given - is that of the page or space in question or is it for the content API of the whole company's confluence
  5. the syntax is basically difficult and seems to exist in a lot of forms based on the chats and forums

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events