Microsoft Lists: Embedding on an external website using Microsoft Graph API

Hal Morrissey Gilman 6 Reputation points
2022-04-08T14:24:06.67+00:00

Hello,

Thanks in advance for any support offered, and hopefully this is the right thread for the job!

I'm using Microsoft Lists to compile some data, and am looking for a way to embed it as a view-only document on a public website that is external from the Sharepoint on which it is hosted.

I can easily create a shareable link that allows external users to view-only the document, but any time I try to actually embed the List using an iframe for example, I receive an error back saying that my.sharepoint.com refused to connect.

I asked the question earlier on a thread elsewhere (see here), and a friendly Microsoft Agent named Sukie very helpfully suggested using the Microsoft Graph API to solve this problem.

In this guidance that they linked to, it is suggested that one use the following HTML code to display the list using a Microsoft Graph API:

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields(select=Name,Color,Quantity)  

Whilst that seems fairly simple, I don't know HTML well enough to know how the GET function fits into HTML web code, nor do I really how to source the {site-id} or {list-id} referenced in the above code.

Any advice that someone in this forum can offer on the above would be really helpful.

Cheers in advance for any support, and let me know if there's something extra I can provide to make that any easier!

All the best,

Hal

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,256 Reputation points
    2022-04-11T07:13:53.19+00:00

    Hi @Hal Morrissey Gilman ,
    According to my research and testing, 'GET' is a HTTP method ,it means "Read data from a resource" .Here is a document about HTTP method you can refer to.

    You can use the following URL to get the {site-id}:(Refer to the image below, the red part is the {site-id})

    GET    https://graph.microsoft.com/v1.0/sites/{hostname}:/{server-relative-path}  
    

    191772-image.png

    Then, go to List setting, and you will see the {list-id} from the browser address ,as shown in the picture below: (the red part is the {list-id}, please change “%7B” to “{” ,and change “%7D” to “}” )
    191766-image.png

    Finally, use the following code to display the list:

    https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields(select=Name,Color,Quantity)  
    

    191718-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.



Your answer

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