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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.