I'm having issues with creating a page (child of another page which I provide the ID for) in the company's Confluence wiki via command line. I get status code 403, which tells me I could not create content with type "page".
My command ("user" and "mycompany" being placeholder names for this post):
curl -u user -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","ancestors":[{"id":54362173}],"space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://mycompany.atlassian.net/wiki/rest/api/content/ | python -m json.tool
It asks for my password and I provide the correct one, and then this is the output I get:
{ "data": { "authorized": false, "errors": [], "valid": true }, "message": "Could not create content with type page", "statusCode": 403 }
I have permissions to create a page via the Confluence interface (and I have, several times), but this seems to be telling me otherwise. Can anyone shed some light into why this is happening and what I can do to fix it?
Also, I should mention I've gotten comment-posting via command-line to work, so I do indeed have permissions for the wiki. But for creating and editing pages via this method, I'm having this problem.
Check the space paramater. I had this error when this was not correct. The error is not informative.
"space":{"key":"My Project"}, Failed with the 403 error
"space":{"key":"MyProject"}, worked.
As per Steven Lancashire post using GET on the parent page will show you the exact name for the space:
curl -u admin:admin https://mycompany.atlassian.net/wiki/rest/api/content/54362173
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is definitely some problem with this. I'm using a password that can successfully download and edit the page, there are no restrictions on the page, I'm admin on the space, and I created the page I'm trying to make a child page of.
Worse, this was working correctly last week, but this week I get a 403 error. Is there any way for a hosted user to get additional debug information to see what the problem is?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like what you are doing is correct, and so I have to assume it is a permission problem. As you probably know, the return code 403 indicates that you are forbidden from performing the action.
Do you have permission to create pages under the ancestor? And does the ancestor definitely exist?
Try performing a GET on https://mycompany.atlassian.net/wiki/rest/api/content/54362173
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.