I use the SharePoint API to access a tenant SharePoint with a SharePoint REST API call that looks like
site_prefix is usually something like
/sites/siteName but I think that it can sometimes also be
/teams/siteName. Given a
webUrl of a driveItem, I was using a regular expression like
re.match(r"/sites/([^/]+)", webUrlPath).group() and this usually works because most sites prefixes start with
However, I've run into a tenant that does not have a prefix like this, but rather their own custom prefix, so their item's
webUrl looks like
https://contoso.sharepoint.com/customname/. I would like to know how to determine that the site prefix here is
customname so that I can plug it into the SharePoint REST API call that I mentioned in the beginning. I assume that this has something to do with "Managed Paths", but I do not know how to find the managed paths programmatically. If necessary, I also have access to the Graph API.
I have considered just trying
/teams/([^/]+), and as last resort
([^/]+), but I think this may not always work because (please correct if I'm wrong) the prefix may also have multiple slashes making it hard to know where the prefix ends and path begins.