Forums

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

Unable to create child page through REST API

FLoureiro May 15, 2020

Hello everyone,

I am trying to create a child page through REST API, but I am always getting:

"message": "A page with this title already exists: A page already exists with the title new page2 in the space with key CM",
"reason": "Bad Request",
"statusCode": 400

This is the HTTP API POST that I am using:

curl -u admin:admin -X POST -H 'Content-Type: application/json' -d '{"type":"page","title":"new page","ancestors":[{"id":110198787}], "space":{"key":"CM"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' http://localhost:8090/rest/api/content/ | python -mjson.tool 

And my question what am I doint wrong?

The issue is with the id?

The id, is from the page where we want to create the child page or if I must add more fields to identify the page in question. My objective is to create a cascade of pages. For example Page C is a child of Page B, and Page B is a child of Page A who is in the root of Space 1.

Thanks in advance!

1 answer

1 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2020

Not the id, the first line of the error message is almost certainly the problem - you already have a page with that title in that space.

FLoureiro May 15, 2020

Ah ok, I didnt notice previously that I cannot have a child page with the same name of the ancestor.

I made a test with other titles and was able to create child pages.

Thanks for the help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events