403 Forbidden while getting email user
Asked by Mehdi:

Hi . i wanna get email adresse for a specific user by accountId and i have a 403 error

```
getEmailUser(accountId) { 
       let url = this.config.apiPath + "/user/bulk?accountId=" + accountId;        
       return AP.request({            
              url : "/rest/api/user/bulk?accountId="+accountId,
              contentType: "application/json", 
              type: 'GET',
              Authorization: "bWJvdWF6emEuc3BlY3RydW1ncm91cGVAZ21haWwuY29tOnd6UGhpRXBWd1JTN0E0aDhrRVRyODhGRg==",
        }).then(function (data) {
            console.log(data)            
            return JSON.parse(data);
        }).catch(function (error) {  
          console.log('error email user => ' + JSON.stringify(error)) 
       });     }
```

i tied this url : wiki/rest/api/user/email?accountId={accountId}

and it return the same error

![error.PNG](/t5/image/serverpage/image-id/151262i1F61BA8A372B024E/image-size/large?v=v2&px=999 "error.PNG")


Answers:
author: Mohamed Amin Bouaziz
body: hello i get the same problem


author: David Bakkers
body: Hello [@Mehdi](/t5/user/viewprofilepage/user-id/4405152)

A 403 error tells you that the request is incorrectly formed, not that the permissions used for the request are incorrect. If the authentication credentials are incorrect or missing from the request, a 401 error is returned.

Your code has a mistake in it. If you look at where you define the URL for the request, you haven't provided the version number of which API to use, like this:

```
url : "/rest/api/3/user/bulk?accountId="+accountId,
```

However, even if you correct the mistake in your code, the API endpoint you've chosen will not tell you the user's email address, only other general information about them, because email addresses are privileged information.

comments: author: Mehdi
body: Hi [@David Bakkers](/t5/user/viewprofilepage/user-id/1575730) thank u for ur reply

I followed this documentation [The Confluence Cloud REST API (atlassian.com)](https://developer.atlassian.com/cloud/confluence/rest/api-group-users/#api-api-user-email-bulk-get) and it was not mentionned this url

```
url : "/rest/api/3/user/bulk?accountId="+accountId,
```

when i tried this url , its poster to me the same error


author: David Bakkers
body: Hello [@Mehdi](/t5/user/viewprofilepage/user-id/4405152)

OK, sorry, I thought you were trying to make a request to the Jira REST API, not the Confluence REST API. For Confluence you don't need to supply the API version in the request URL.

However, the underlying cause of a 403 error is still that you are making an invalid request, so there is either a mistake in your code or the structure of the request.

Even if you do fix the mistake in your code *and* send a properly formed request to that REST API endpoint *and* use the appropriate permissions, it will just return a *400 Bad Request* response with the message:
> com.atlassian.confluence.api.service.exceptions.BadRequestException:
>
> This API is only available to approved Connect apps

...because the documentation for that endpoint specifically says it *"Returns user email addresses for a set of accountIds. **This API is only available to apps approved by Atlassian** , according to these [guidelines](https://community.developer.atlassian.com/t/guidelines-for-requesting-access-to-email-address/27603)."* and your code does not meet the criteria described in those guidelines.

If you use a REST API test tool like [Postman](https://www.postman.com/), as I've recommended you do in other posts elsewhere, you would have discovered that all this is true:

![Annotation 2021-07-16 073638.png](https://community.atlassian.com/t5/image/serverpage/image-id/151614iD12C82B95E49473F/image-size/large?v=v2&px=999 "Annotation 2021-07-16 073638.png")

I think you should spend some more time reading the documentation on how to use the REST API, what the different response codes indicate, and testing your code to see if you are sending a valid and correctly authenticated request place in the first instance.


author: Mehdi
body: Hello

when i use the same url on browser or postman , they send me the result i wanted

![Postman.png](https://community.atlassian.com/t5/image/serverpage/image-id/151656i9A89AF9AC390A4F3/image-size/large?v=v2&px=999 "Postman.png")


author: Benjamin
body: [@Mehdi](/t5/user/viewprofilepage/user-id/4405152) ,

The User you are using to get information, does it have full access to retrieve information. Also, is there any login issue with this user from the UI?

comments: author: Mehdi
body: [@Benjamin](/t5/user/viewprofilepage/user-id/3275402) Yes he has all permissions .

User can see all informations from this URL when he is connected from browser


Tags: cloud

confluence-cloud

rest-api