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 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();
Anonymous
Feb 27, 2018Maybe VesaJuvonen can help with this issue. Or there must be made a ticket as i think the url is OK