Articles

How to fetch saved for later pages in SharePoint online

How to fetch saved for later pages in SharePoint online

In this article we will see how we can access the saved for later pages data programmatically.

What are saved for later pages in SharePoint online

Microsoft have released a new feature in SharePoint online which can be used to save the link of  SharePoint pages for later. It is like book mark.
When you save a page for later then a link to that page is saved some where.
When you browse a page then in the bottom next to views there is save for later. To save a page for later you can click on the icon next to save for later. as shown in the image below.
Saved for later items  | saved for later pages in SharePoint online tutorialsinhand

How to fetch saved for later pages data programmatically.

After doing some investigation, I found that saved for later pages can be fetched from an api called Microsoft home service api which is located at
https://tenantloc-sphomep.svc.ms/
where tenant Location is the region.
in order to fetch the data first you need to get the access token. you can get access token by issueing a get request to below url
 
https://<your-tenant>.sharepoint.com/_api/sphomeservice/context?$expand=Token

you will get two things.

1. access_token : will be the token that will be used to authenticate to sphome services api.

2. resource : this is url along with the location.

Once you have these two things you can get the data of saved for later pages as shown below.

 

Get saved for later pages data

In order to fetch save for later pages data , we need to issue a get request to below end point.

&lt;resource url abouve&gt;/api/v1/documents/saveForLater?start=0&count=100

 Along with the get request you also need to pass a header 

headers: {
'authorization': `Bearer &lt;access-token&gt;`,
'sphome-apicontext': `{"PortalUrl":"&lt;your sharepoint online url&gt;"}`
}

in the result set you will get top 100 saved pages in SharePoint.

 

How to add a page in Saved for Later list

In order to add a page in saved for later pages list we need to issue a get request to below end point.
 
resource url obtained/api/v1/documents/saveForLater/add?siteId=&lt;siteid&gt;&webId=&lt;webid&gt; &listId=&lt;list id&gt; &uniqueId=&lt;unique id of the page&gt;

After issueing this request your page data will be saved in Saved for Later pages list.

 

How to remove a page from Saved for Later pages list

In order to remove a page from saved for later pages list , we need to issue a get reques to below end point.

resource url obtained/api/v1/documents/saveForLater/remove?siteId=&lt;site id&gt;&webId=&lt;web id&gt; &listId=&lt;list id&gt; &uniqueId=&lt;unique id of the page&gt;

Note : this api has not yet been documented by microsoft and thus not recomended for use

If you want step by step of how to create a webpart to show the save for later pages data then have a look on this article
 

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com
Page Views : 62    Published Date :Sep 22,2019   Author :Mukesh Tiwari
Please Share this page

Popular Articles

Loading...
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn moreGot it!