Forum Discussion
CardinalNight
Oct 04, 2023Copper Contributor
How to retrieve all hubsites and associated sites using SPFx and sp/PnP
I have the below code and this retrieves what I believe is all the hubsites in my tenant: export const GetHubSites = async () => {
const _sp = getSP();
const finalArray: any[] = [];
const hub...
- Oct 05, 2023
CardinalNight You have to pass the parent hub site ID to DepartmentId property to fetch the associated SharePoint sites with that particular hub site.
Check the links given in my above response once.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
CardinalNight
Oct 05, 2023Copper Contributor
Hi Ganesh,
Thanks for your reply, but I need to understand what filters to use to get hubsites AND their children sites. I understand that it may require a separate API call, but to narrow down my question, what are the different filters to use to get hub sites and their associated child sites?
E.G I use const url = rootSite + "/_api/search/query?queryText='DepartmentId:{" + hubID + "} contentclass:STS_Site'&trimduplicates=false&selectproperties='Title,Path,DepartmentId,SiteId,IsHubSite'&rowlimit=1000";
Thanks for your reply, but I need to understand what filters to use to get hubsites AND their children sites. I understand that it may require a separate API call, but to narrow down my question, what are the different filters to use to get hub sites and their associated child sites?
E.G I use const url = rootSite + "/_api/search/query?queryText='DepartmentId:{" + hubID + "} contentclass:STS_Site'&trimduplicates=false&selectproperties='Title,Path,DepartmentId,SiteId,IsHubSite'&rowlimit=1000";
ganeshsanap
Oct 05, 2023MVP
CardinalNight You have to pass the parent hub site ID to DepartmentId property to fetch the associated SharePoint sites with that particular hub site.
Check the links given in my above response once.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.