Forums

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

Curl request to update the page gives BadRequestException: A page with this title already exists: A

atalwar November 2, 2021

I'm trying to update a page. while running the curl request it gives me an error 

BadRequestException: A page with this title already exists: A page already exists with the title

 

Code:-

 

echo '{"id":"xxxxxx","type":"page","title":"'${releaseVersion}'","space":{"key":"~xxxxxx"},"body":{"storage":{"value":"'$TEXT'","representation":"storage"}},"version":{"number":'$PAGE_VERSION'}}' > update1.json

curl -u 'xxxxxx@xxxxxx.xxxx:xxxxxxx' -X PUT -H 'Content-Type: application/json' -d '@update1.json' https://xxxxxx.xxxxx.net/wiki/rest/api/content/xxxxxxx | python -mjson.tool

rm update1.json

 

If I change the title to something NEW it creates a NEW PAGE. However, I don't want a new page, I want to update the same page.

1 answer

0 votes
marc -Collabello--Phase Locked-
Community Champion
November 3, 2021

If you want to update the same page, you need to increment the version number, see https://developer.atlassian.com/cloud/confluence/rest/api-group-content/#api-wiki-rest-api-content-id-put .

atalwar November 3, 2021

Hi Marc,

 

 

I'm incrementing the version by 1. However, I keep the title as same.

"title":"'${releaseVersion}'"

 Keeping the title as the same gives an error that the page already exists.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events