question

KevinThankachan-4898 avatar image
0 Votes"
KevinThankachan-4898 asked ·

MS Team App to fetch SharePoint list item

I'm following the below link to create a personal tab in a Team App.

https://docs.microsoft.com/en-us/microsoftteams/platform/build-your-first-app/build-personal-tab

I need to fetch and display contents from a SharePoint list here. I get the below error-

{"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

The user is a SharePoint Administrator and Site collection Admin.

Code-

 var spUrl="https://****.sharepoint.com/sites/Project4thCOM2"; //hard coded SP Site URL
 var web = Web(spUrl); 

 await web.lists.getByTitle("Teams List").items().then((items)=>{
   items.forEach(element=>{
       this.setState({
         Title:element['Title'],
         SingleLine:element['SingleLine']
         })
   })
 }).catch(err=>console.log(err))

Could anyone please suggest how we can access the SharePoint list data here.
Regards,
Kevin

office-sharepoint-onlineoffice-teams-app-dev
10 |1000 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.

1 Answer

AmosWu-MSFT avatar image
0 Votes"
AmosWu-MSFT answered ·

You need to get the access token to request the API.
Integrating SharePoint Data Into Node.JS With Access Token
Or you may try to use Graph API.
Tutorial:Calling Microsoft Graph from your Teams application


If the response 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.

· 2 ·
10 |1000 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.

@KevinThankachan-4898, please let us know if your issue has been resolved.

0 Votes 0 ·

finally got it working. Had to fix couple of webpack and module issues.
Thank you.

0 Votes 0 ·