Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

403 Forbidden while getting email user

Mehdi July 13, 2021

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

 

3 answers

0 votes
Mohamed Amin Bouaziz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 9, 2024

hello i get the same problem

0 votes
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2021

Hello @Mehdi 

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.

Mehdi July 15, 2021

Hi @David Bakkers  thank u for ur reply

I followed this documentation The Confluence Cloud REST API (atlassian.com) 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 

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2021

Hello @Mehdi 

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." and your code does not meet the criteria described in those guidelines.

If you use a REST API test tool like Postman, 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

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.

Mehdi July 16, 2021

Hello 

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

 

Postman.png 

0 votes
Benjamin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 13, 2021

@Mehdi ,

 

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?

Mehdi July 14, 2021

@Benjamin Yes he has all permissions  .

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events