Forums

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

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

Cristiano Sticca January 3, 2025 edited

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 Champion
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 Champion
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 Champion
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 Champion
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 Champion
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 ...

Mansi Gusain
Contributor
March 4, 2025 edited

  Hi ,  I am also experiencing the same issue this is my schema. I am facing the 404 issues in the backend when I try to find the space using the id. In the postman I am using the basic auth but in the schema below ouath-bearer auth. The api are 

https://name.atlassian.net/wiki/api/v2/spaces?keys=name (get)

 

https://name.atlassian.net/wiki/api/v2/pages (post). 

 

Have i made a mistake here?

openapi: 3.1.0
info:
title: Atlassian Confluence API
version: 1.0.0
servers:
- url: https://sample.atlassian.net/wiki/api/v2
- description:  Confluence Server
paths:
/spaces:
get:
operationId: getSpaceInformation
summary: Retrieve space information
parameters:
- in: query
name: keys
required: true
schema:
type: string
description: The key of the space to retrieve
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
id:
type: string
security:
- bearerAuth: []

/pages:
post:
operationId: createPage
summary: Create a new page
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
spaceId:
type: string
status:
type: string
title:
type: string
parentId:
type: string
body:
type: object
properties:
representation:
type: string
example: storage
value:
type: string
required:
- spaceId
- status
- title
- body
responses:
'200':
description: Page created successfully
security:
- bearerAuth: []

components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events