Forum Discussion
PapagenoSweden
Feb 23, 2018Copper Contributor
Cannot get modern team sites with REST
Hi, guys!
I use a REST call to retrieve all sites the current user is following, but modern team sites don't show. I get all classic sites and also modern communication sites, but not modern te...
PapagenoSweden
Feb 25, 2018Copper Contributor
Hi, Paul, and thanks for your reply.
If you're referring to the Privacy Settings dropdown in the Site Information pane, all my modern team sites are "Public". But no one is returned by my REST call. Are there any other settings needed?
Funny thing is that when I go to the page https://[tenant]/_layouts/15/sharepoint.aspx, I find a "following" section in the left nav. In this section all the sites I'm following appear, regardless of they being classic, communication or what not. It is this behaviour I'm trying to mimic using my REST call. Without any luck, obviously. Any other suggestions?
PapagenoSweden
Feb 27, 2018Copper Contributor
Apparently, this subject has been up for discussion before. I found this post which describes my problem in a nutshell. A modern team site uses GROUP as web template and above mentioned post had a solution. Thanks.
The solution in this case was to use a web service instead and call it with a good old XMLHttpRequest. Here's a sample if anyone else have the same issue.
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ var followedSites = []; if (xhr.readyState==4 && xhr.status==200) { var data = JSON.parse(xhr.responseText); for(var i=0;i<data.Items.length;++i){ followedSites.push({ Acronym: data.Items[i].Acronym, Title: data.Items[i].Title, Url: data.Items[i].Url }); } console.log(followedSites); } }; xhr.open('GET', this.context.pageContext.web.absoluteUrl + '/_vti_bin/homeapi.ashx/sites/followed?mostRecentFirst=true&start=0&count=100&fillSiteData=true', true); xhr.send();
- DeletedFeb 28, 2018
Maybe VesaJuvonen can help with this issue. Or there must be made a ticket as i think the url is OK