Search code examples
curlresponseconfluenceconfluence-rest-api

Confluence REST API: HTTP 200 w/ Empty Response


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:

  1. Adding ?os_authType=basic to the end of the URL

  2. Adding as many parameters as possible (all with empty values) such as:

    • status: current
    • operations: []
    • metadata: {}
  3. Changing the API call to create a page at the top level within the Confluence space (omitting the ancestors field).

  4. Adding this header: Accept: application/json

  5. 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).


Solution

  • 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/