Retrive User profile propertes using javascript rest api in sharepoint online

Mahesh C M 156 Reputation points
2021-03-10T14:13:06.413+00:00

Hi Guys,

I have a sharepoint hosted app. In the application i have facing an issue in retrieving user profile properties using rest api call in javascript. Got an unauthorized exception while accessing the api. try to resolve this issue by provide a tenant read permission to application and then deploy the application , there is a deploy request has been send to the tenant admin , i have the tenant admin access and i approved the deployment request but nothing happens. Could anyone help me what is the best method to get the user profile from sharepoint online.

I have tried javascript object model to retrieve the user data. there also i got the same issue .(below given the link)

https://learn.microsoft.com/en-us/sharepoint/dev/general-development/how-to-retrieve-user-profile-properties-by-using-the-javascript-object-model-in#bk_CreateAppPage

Microsoft 365 and Office SharePoint For business Windows
Microsoft 365 and Office Development Microsoft 365 Publishing
{count} votes

Accepted answer
  1. ZhengyuGuo 10,586 Reputation points Moderator
    2021-03-11T02:59:22.39+00:00

    Hi @MaeshCM-7927,

    You can use Rest API to get user Profile Propeties in SharePoint Hosted app like this:

    76518-snipaste-2021-03-11-10-45-58.png

    76487-getuserprofile.txt

    App Permision:

    76499-snipaste-2021-03-11-10-51-59.png

    While deploying, directly clicking the Trust:

    76460-snipaste-2021-03-11-10-58-54.png

    76488-snipaste-2021-03-11-10-45-06.png

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.