Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to create a new Confluence page with the REST API

Ryan Greene
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2017

Hello,
I am attempting to create a new Conflunce page using the REST API as described here:
https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples
and
https://docs.atlassian.com/atlassian-confluence/REST/latest/#content-getContent

I get a successful response, however the return is the HTML for our main confluence page, not what I expected to get back as described in the documentation.

This issue appears to be very similar, if not identical to this problem:

https://community.atlassian.com/t5/Confluence-questions/Why-does-Confluence-REST-API-return-html/qaq-p/42841
Which appears unresolved still.

Here's what I'm doing:
curl -u XXXXX:XXXXX -X POST -H 'Content-Type:application/json' -d'{"type":"page","title":"new page","space":{"key":"T4T"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://dev-confluence.server.com/confluence/rest/api/content/

Where T4T is my space key.

I've tried adding an ancestor to an existing page in the space, as well as removing the space key with the ancestor, nothing seems to be working.

Any suggestions?

1 answer

1 vote
Chris Watkins
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2018

Removing the "/confluence" from the url seemed to fix this problem for me. So your url above would become

 

https://dev-confluence.server.com/rest/api/content/

 

Dunno, if it will help you, but it certainly did me!

dgetme
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2020

Hi Chris,

Have been hitting my head around for a while unable to find a solution to this one and this works like a charm. Thanks a ton.

Removing confluence from the url is a perfect fix.

The Confluence API document needs to be updated. - https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/

I'll request for a correction.

Like nicholasparsonage likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events