Forums

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

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

정예린
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!
April 2, 2020

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
Dominic Cousins
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!
May 5, 2020

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.

정예린
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!
May 11, 2020

thanks, dominic. 

0 votes
Dominic Cousins
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!
May 5, 2020

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
AUG Leaders

Atlassian Community Events