Forum Discussion
Cannot get modern team sites with REST
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?
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();
- AnonymousFeb 27, 2018
Maybe VesaJuvonen can help with this issue. Or there must be made a ticket as i think the url is OK