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:
- will the basic authentication with user/pw work for page creation? (will move to API token after it works)?
- what is the -D- switch and why is this form of the curl command different
- 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
- 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
- the syntax is basically difficult and seems to exist in a lot of forms based on the chats and forums