Facing issue (404) when creating a page using REST v2 API

Cristiano Sticca January 3, 2025

Hi community!

I'm facing an issue when I'm trying to create a page on confluence cloud using API v2.

When I use this

GET 'https://companyname.atlassian.net/wiki/api/v2/pages

I have results correctly but when I use the API to create a new page I have 404 

POST 

https://companyname.atlassian.net/wiki/api/v2/pages

with this body

{
"spaceId": 21987908,
"status": "current",
"title": "Test",
"body": {
"representation": "storage",
"value": "Test"
}
}
Thanks in advance!

2 answers

1 accepted

1 vote
Answer accepted
Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

Hi @Cristiano Sticca 

As mentioned here:

https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-post

404 Not Found

Returned if:

  • The space does not exist
  • The user does not have permissions to view the space
  • The user does not have the needed permissions to create a page in the provided space

Check the space permissions.

Ive tested this:

https:/my.atlassian.net/wiki/api/v2/pages with a POST and this body and it works.

{

    "spaceId": "33009",

    "status": "current",

    "title": "Interesting page title",

    "parentId": "33096",

    "body": {

        "representation": "storage",

        "value": "<p>The page content</p>"

    }

}

 Regards

Aaron

Cristiano Sticca January 3, 2025

Thanks @Aaron Pavez _ServiceRocket_ for your quick reply. 
Can you help my on checking my permission? Because with my user I can create pages on the space so I don’t know where the problem about permissions is. 
thanks again 

Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

Hi @Cristiano Sticca 

Can you test the body I used? On yours, you are missing this:

"parentId": "...", you need to tell confluence which page is the parent page.
As for the permissions, what user API token are you using? yours?
regards
Cristiano Sticca January 3, 2025

Hi @Aaron Pavez _ServiceRocket_ yes I used also the same body you used but same error. 
I’m using my API token the same I use for the other API (get pages) that works.

Maybe I’m wrong with the space and parent id? Is there a friendly way to get them, I mean get them directly from Confluence pages?

Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

Hi again!

The Space ID? Not from the UI, only with API.

/wiki/rest/api/space/SPACEKEYHERE

Double check the space ID and parent page ID.Y

You can get the page ID from the UI by going to More actions -> Advanced details -> Page information

Regards

Cristiano Sticca January 3, 2025

Nope :/ 

--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"spaceId": "415367805",
"status": "current",
"title": "Interesting page title",
"parentId": "853541359",
"body": {
"representation": "storage",
"value": "<p>The page content</p>"
}
}'
Response:

{
"errors": [
{
"status": 404,
"code": "NOT_FOUND",
"title": "Not Found",
"detail": null
}
]
}
Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

Hi!

Can you try the curl command from the Atlassian page?

curl --request POST \

--url 'https://{your-domain}/wiki/api/v2/pages' \

--user 'email@example.com:<api_token>' \

--header 'Accept: application/json' \

--header 'Content-Type: application/json' \

--data '{

"spaceId": "<string>",

"status": "current",

"title": "<string>",

"parentId": "<string>",

"body": {

"representation": "storage",

"value": "<string>"

}

}'

Regards

Cristiano Sticca January 4, 2025

@Aaron Pavez _ServiceRocket_ now it works, I don't know how but in postman I had a problem with my token :(

Thanks for the support!

0 votes
Cristiano Sticca January 3, 2025

Hi!

How? I'm using the curl with Postman but don't know how to use it in the Atlassian page :/ 

Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

With postman you dont need to user curl.

2025-01-03 17_10_37-https___sitehere.atlassian.net_wiki_api_v2_pages - Jira_Confluence.jpg

add the URL

in authorization

- Username: use your email 

Password: your token

the body is the one I've shared earlier. select raw and JSON at the end.

That should do it.

regards

Cristiano Sticca January 3, 2025

Here you have:

 

1) the API that works (Get Pages)

Screenshot 2025-01-03 alle 21.16.03.png

 

2) the API that doesn't work (Create Page)Screenshot 2025-01-03 alle 21.16.24.png

 

Same url, same user, same API token ...

Suggest an answer

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

Atlassian Community Events