Getting 404 and 403 using Rest API and Rest API V2
Asked by Mohammad Zaman:

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  

<br />

**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

}

```

<br />

<br />

**Using Rest API V2: T** here 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](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get)   

```
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
    }
  ]
}
```

<br />

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"
],
```

<br />

<br />


Answers:
author: Mohammad Zaman
body: 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  

<br />

<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)
```

<br />

**api: is the format from REST API V2: ([REST API V2](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get) )**   
/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)](https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#3--make-calls-to-the-api-using-the-access-token)

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

hope this helps.


author: Alex Koxaras _Relational_
body: Hi [@Mohammad Zaman](/t5/user/viewprofilepage/user-id/5205226) and welcome to the community,

Have you try using <https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-custom-content/#api-custom-content-id-get> ?

comments: author: Mohammad Zaman
body: Hi [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197) ,

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

 }

 ]
```


author: Mohammad Zaman
body: [{ATLASSIAN_DOMAIN}/wiki/api/v2/custom-content/2654211](http://{{ATLASSIAN_DOMAIN}}/wiki/api/v2/custom-content/2654211)


author: Selva Stalin
body: Facing same issue


author: Mohammad Zaman
body: ```
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

}
```

<br />

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

[Personal Access Token](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html)   

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'
```


author: Mohammad Zaman
body: ...


Tags: cloud

confluence-cloud