sharepointsharepoint-onlineuser-profilesharepoint-jsomsharepoint-userprofile

Read Sharepoint online UserProfiles from sharepoint hosted app using JSOM


I'm trying to get the sharepointonline userprofiles from sharepoint hostedapp by refering the below MSDN

https://dev.office.com/sharepoint/docs/general-development/how-to-retrieve-user-profile-properties-by-using-the-javascript-object-model-in

but when am trying to execute the code it throws the following error "Error: Access denied. You do not have permission to perform this action or access this resource".

In above artical they have mentioned to enter the "domainName\\userName", here am just confused whether which domain I should give either my app domain or my sharepointonline domain.

Since i tried both the domains but the issue remains same.

Anyone please advice...

Thanks in advance


Solution

  • You are getting access denied because your hosted app does not have to required permission to execute user profiles.

    On your SharePoint Hosted App solution AppManifest.xml grant the necessary permission for your app to access. In your case it would be:

    enter image description here

    Depending on your usage you may require to grant it more than just "Read".