Any confluence REST call returns 404

jkazan January 28, 2019

I am trying to get a confluence page, and my final goal is to modify it, but I seem to get a 404 return regardless of what I call. I am using the Jira REST quite a lot, which works fine, but for confluence I have no idea what is wrong.

I have admin privileges to the entire chain of pages and my python code is as follows:

auth = (<myUser>, <myPassword>)
headers = {'Content-Type' : 'application/json'}
url = "https://<myDomain>/confluence/rest/api/content/295789998?expand=body.storage"

response = requests.get(url, auth=auth, headers=headers)
print(response)

which prints:
<Response [404]>

In pure desperation I tried regular curl calls as well, of course with the same result.

I have tried virtually all type of calls found at:
https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/

and they all return 404 (page not found)

 

All help is much appreciated!

 

EDIT:

 

I also tried with an api token as below, and got a 401 error (unauthorized):

import requests
from requests.auth import HTTPBasicAuth
import json

url = "https://<myDomain>/confluence/rest/api/content/295789998?expand=body.storage"
token = "<myAPIToken>"
auth = HTTPBasicAuth(user, token)

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 What am I doing wrong?

5 answers

2 votes
Sebastian Vaughan May 14, 2020

I know this is monumentally late, but I'm using Confluence Server (installed via https://hub.docker.com/r/atlassian/confluence-server/ docker - tag 7.5.0-rc1-ubuntu) and I ran into this same problem earlier.

My nodejs app was hitting

http://localhost:8090/confluence/rest/api/space

Turns out the /confluence at the start is part of the context path, Confluence was expecting me to hit

http://localhost:8090/rest/api/space

 When I passed the Authorization header with base64 username, password, correct user permissions etc. it all worked!!! I haven't tested other REST API endpoints, but I'm sure it's the /confluence in my installation that makes it do that.

Hope I helped someone :)
Thanks, Seb

Sebastian Vaughan May 14, 2020

Additionally, when I typed

http://localhost:8090/rest/api/accessmode

into my browser, I saw

"READ_WRITE"

in the window.

Probably test this first to see if the path /rest/api is correct for you.

0 votes
Ben Johnson February 13, 2023

I'm getting this same error. Any solutions out there?

0 votes
zhangyihan December 16, 2019

 i also run into this problem. cloud someone give me a solution?

using python jira package and python requests package all will  happend 

0 votes
Darshan_Rudresh October 28, 2019

Hello,

 

I am also facing a 404 whenever i try to request a rest api call in my local confluence server.

I tried the request in postman as well still ended up in the same 404 page. 

I am using this URL: http://localhost:8080/confluence/rest/api/content . My Server is up and running when i try hit this URL in the browser i can see that page not found (404)

Could anyone let me know why is this?

 

Thanks

Darshan

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 28, 2019

Hello there!

Could you clarify one specific thing for us:

- What happens if you try this, directly on the browser that you use to access Confluence:

https://yourdomain.com/confluence/rest/api/content/295789998?expand=body.storage

 Is there any kind of return from the server?

Puneet Gupta May 15, 2019

facing same issue, and above link is also giving same error.

below link is working:-

https://mydomain/rest/api/2/issue/createmeta

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events