Forums

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

Confluence API copy page causing 404 error

Woodson Miles October 21, 2021

Trying to make a copy of a single page within the same confluence space using the API as exemplified here.

I'm getting this 404 error:

"null for uri: https://docs.my.company.com/rest/api/content/491102008/copy","status-code":404}'

My python code:

import requests
from requests.auth import HTTPBasicAuth
import json

url = 'https://docs.my.company.com/rest/api/content/491102008/copy'
headers = {'Content-Type': 'application/json',
"Accept": "application/json;charset=UTF-8"}
auth = HTTPBasicAuth('username', 'password')
payload = json.dumps({
"destination": {
"type": "space",
"value": "MYSPACE"
},
})
response = requests.post(url, headers=headers, data=payload, auth=auth)
response.raise_for_status()
return response

 

I've tried copying many different pages with different ids and a couple different spaces without changing the error.

The URL 'https://docs.my.company.com/rest/api/' has worked for my other API functions, as does my 'headers' and 'auth' parameters.

My company's instance of confluence is version 7.4.3

2 answers

1 accepted

2 votes
Answer accepted
Thomas Deiler
Community Champion
October 21, 2021

Dear @Woodson Miles ,

welcome to the community.

The endpoint 

GET /rest/api/content/{d}/copy

does not exist in the rest api reference. That's why it doesn't work. You are referencing to the CLOUD Api. Server is different.

To do what you want, you need to call first

GET /rest/api/content/{id}

read the page body, modify and then create with:

POST /rest/api/content

So long

Thomas

Mansi Gusain
Contributor
March 4, 2025

Hi I am also experiencing the 404 issue. I am using the apis- 

 

Get /wiki/api/v2/spaces?keys=anyname 

 

and 

 

Post /wiki/api/v2/pages?keys=SUPKB

 

So it is failing with 404 

 

this is my schema- 

 

openapi: 3.1.0
info:
title: Atlassian Confluence API
version: 1.0.0
servers:
- url: https://domain.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

0 votes
Michael Aglas
Contributor
August 31, 2022

ok, so this is not about the API, but REST API and therefore not what I was looking for...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events