Forum Discussion
How to retrieve all hubsites and associated sites using SPFx and sp/PnP
- 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.
You may need to use separate API call for fetching associated sites for each hub site. Check below resources for more information:
- @pnp/sp/hubsites
- SPFx: pnp.sp.search how to get all associated sites using hub site name
- REST – Get Associated Sites of a SharePoint Hub Site
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.
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";
- ganeshsanapOct 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.