I cannot seem to create a new page on Confluence Cloud v1000.957.0 via the Rest API. I have tried both using cURL and Python to no avail: all I get back is HTTP 200
with an empty JSON response every time. If I change the credentials to be incorrect, I get HTTP 401
.
curl -u ******@******.com:****** -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"TESTING123", "ancestors":[{"id":123456}], "space":{"key":"AA"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://********.atlassian.net/wiki/rest/api/content/
I have changed a few details of the cURL call for the sake of anonymity, but I know the credentials, ancestor ID, space key, and API URL are correct. I have also verified that this account has the correct permissions in Confluence to create a page in this space, and that API access for Confluence is enabled.
Variations on the API call that I have tried:
Adding ?os_authType=basic
to the end of the URL
Adding as many parameters as possible (all with empty values) such as:
status: current
operations: []
metadata: {}
Changing the API call to create a page at the top level within the Confluence space (omitting the ancestors
field).
Adding this header: Accept: application/json
Adding the view
option to the body
portion of the call and subsequently appending this to the end of the URL: &expand=body.view
. I have found that adding it to the Python code gives the same result, but adding it to the cURL call prints out something like [1] 42999
(the latter part changes with each call); then upon a new command or simply upon pressing Return
, it prints [1]+ Done
followed by a chunk of whitespace, then the cURL call I just made.
I found a very similar bug in Atlassian's JIRA for JIRA software, so apparently this happens for JIRA as well, but intermittently. https://jira.atlassian.com/browse/JRA-41559
I'm not terribly familiar with HTTP protocol, so there may be something I am overlooking, so really I just want more options to try (although a solution would be ideal, of course).
The problem is that you're using username with domain as credentials (******@******.com:******)
You can check if this is working just by asking for main wiki content.
Try:
curl -u <user>:<pass> https://<domain>.atlassian.net/wiki/rest/api/content/
You can also ommit password. Curl will ask for it - it's safer from security perspective.
Try:
curl -u <user> https://<domain>.atlassian.net/wiki/rest/api/content/