It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

why creat content rest api not working? post api not working

I want to create content using confluence rest api.

I am running nodejs  to create page content in confluence REST API.

 

var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"title":"new page","type":"page","space":{"key":"MYSPACEKEY"},"ancestors":[{"id":123456}],"body":{"storage":{"value":"<p>first page</p>","representation":"view"}}});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw
};

fetch("http://domain.atlassian.net/wiki/rest/api/content", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

 

That response 200 code, however I am getting the "get api result" not the "post response".

And it doesn't create new page. What is wrong?

2 answers

1 accepted

0 votes
Answer accepted

The solution is that you are (and I was also) visiting http://confluence-url but you should instead specify https.

https://domain.atlassian.net/wiki/rest/api/content

That cost me an embarassing amount of time to solve.

thanks, dominic. 

Did you find a solution to this problem?

I am having the exact same issue - POST requests to the create content end point don't create content and instead return the GET content response.

Thanks,

Dominic

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,368 views 6 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you