Getting 404 and 403 using Rest API and Rest API V2

Mohammad Zaman April 26, 2023
Hello, 
I am trying to call Confluence Cloud V2 Rest API using the access token by using 3LO Authentication mechanism (code grant). 

I can generate an Access_Token and also see correct scopes.

I tried using the REST API and REST API (v2). 

I get the pageId from the Page Information
{ATLASSIAN_DOMAIN}/wiki/pages/viewinfo.action?pageId=2654211


Using Rest API V1:  (DEPRECATED)
curl --location --request GET 'https://{ATLASSIAN_DOMAIN}/wiki/rest/api/content/{id}' \

--header 'Authorization: Bearer {ACCESS_TOKEN}


RESPONSE:

{

"message": "Current user not permitted to use Confluence",

"statusCode": 403

}



Using Rest API V2: There is no API documentation for v2 for getting content by pageId.
However, I tried using the V2 GET Page By Id:

Get Page By Id V2 

curl --location --request GET 'https://{domain-name}.atlassian.net/wiki/api/v2/pages/2654211' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Accept: application/json'
Response: 
{
"errors": [
{
"status": 404,
"code": "NOT_FOUND",
"title": "Not Found",
"detail": null
}
]
}

 
I can retrieve and see the scopes by calling 
https://api.atlassian.com/oauth/token/accessible-resources
with the Access_Token:

curl --location --request GET 'https://api.atlassian.com/oauth/token/accessible-resources' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Accept: application/json'


"scopes"
: [
"write:space:confluence",
"read:content-details:confluence",
"read:space-details:confluence",
"read:space.permission:confluence",
"read:space:confluence",
"read:custom-content:confluence",
"write:content.property:confluence",
"write:page:confluence",
"read:content.property:confluence",
"read:user:confluence",
"write:content:confluence",
"read:content.permission:confluence",
"read:content:confluence",
"read:attachment:confluence"
],



2 answers

1 accepted

0 votes
Answer accepted
Mohammad Zaman September 29, 2023


I found the problem while using the access-token obtained from AuthGrantCode.

I was using the https://{company-name}.atlassian.com/...;whereas, i should have used


https://api.atlassian.com/ex/confluence/{cloudID}/{api}

The cloudid - can be obtain from :

curl --location 'https://api.atlassian.com/oauth/token/accessible-resources' \

--header 'Authorization: Bearer AccessTOKEN' \

--header 'Accept: application/json'

/// Access Token Obtained using AuthGrantCode (in my case)


api: is the format from REST API V2: (REST API V2 )
/wiki/api/v2/pages/{pageID}?body-format=storage

So, the resulting api url will look like:

https://api.atlassian.com/ex/confluence/{cloudID}/wiki/api/v2/pages/{pageID}?body-format=storage

or..

curl --location 'https://api.atlassian.com/ex/confluence/{cloud-ID}/wiki/api/v2/pages/{PAGE_ID}?body-format=storage' \

--header 'Authorization: Bearer Access_Token' \

--header 'Accept: application/json'

 

Detail Doc / explanation can be found here : OAuth 2.0 (3LO) 

NOTE: Must have necessary granular scopes that you can grant permission to in the developer console..

 

hope this helps.  

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 30, 2023
Mohammad Zaman May 1, 2023

Hi @Alex Koxaras _Relational_ , 

Thank you for replying. I tried with custom-content by Id, i still get 404

{

"errors": [
{
"status": 404,

"code": "NOT_FOUND",

"title": "Not Found",

"detail": null

}

]
Selva Stalin June 14, 2023

Facing same issue

Mohammad Zaman June 18, 2023
curl --location --request GET 'https://{DOMAIN_NAME}.atlassian.net/wiki/rest/api/content/{PageID}?expand=body.view' 

--header 'Authorization: Bearer {BEARER_TOKEN}'



Response:
{

"message": "Current user not permitted to use Confluence",

"statusCode": 403

}


Using JWT Access_Token did not work neither for Rest Api V1 nor V2. Using the PAT (Personal Access Token) worked. 

Personal Access Token 

REST API V1

curl --request GET \
--url 'https://{DOMAIN_NAME}.atlassian.net/wiki/rest/api/content/{pageId}'?expand=body.view \
--user 'email@example.com:<PERONAL_ACCESS_TOKEN>' \
--header 'Accept: application/json'
Mohammad Zaman September 29, 2023

...

Suggest an answer

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

Atlassian Community Events