question

MaheshCM-7927 avatar image
0 Votes"
MaheshCM-7927 asked MaheshCM-7927 commented

Retrive User profile propertes using javascript rest api in sharepoint online

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://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-retrieve-user-profile-properties-by-using-the-javascript-object-model-in#bk_CreateAppPage


office-sharepoint-onlinemicrosoft-365-apps-publishing-dev
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @MaheshCM-7927 ,

Is there any update ? Did the code work to get user profile properties in Add-in ?

Thanks
Best Regards

0 Votes 0 ·

Hi @Jerryzy-MSFT ,

Sorry for the late reply. I have go through the solution you shared,but it doesn't worked for me.There is an access denied error throwing. But this rest api url i can able to load in a browser and get required details.

Thanks
Best Regards

0 Votes 0 ·
Jerryzy avatar image Jerryzy MaheshCM-7927 ·

Check about the AppManifest.xml settings, make sure the persmission has been set like in answer.

As you can get the required response data using the rest endpoint, so it's no problem achieve the same in the Add-in.

0 Votes 0 ·
Show more comments

1 Answer

Jerryzy avatar image
0 Votes"
Jerryzy answered

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.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.