The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Hi @Sayantan Ganguly,
This might caused by you don't have enough permission to the subsite. Although you have permission to access the parenet sites. But some subsites have been granted unique permissions. This means if you are not the member of the sites, you will be unable to get the site. To fix the 401 unauthorized, you will need to check if you have the permission to the subsites or delete the unique permission of the subsites.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.