diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py index 5d30f93ba341e..a311607aa478d 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py @@ -130,9 +130,8 @@ def _get_site_id_with_host_name(self, access_token, sharepoint_site_name) -> str if hasattr(self, "_site_id_with_host_name"): return self._site_id_with_host_name - site_information_endpoint = ( - f"https://graph.microsoft.com/v1.0/sites?search={sharepoint_site_name}" - ) + site_information_endpoint = f"https://graph.microsoft.com/v1.0/sites" + self._authorization_headers = {"Authorization": f"Bearer {access_token}"} response = requests.get( @@ -145,7 +144,14 @@ def _get_site_id_with_host_name(self, access_token, sharepoint_site_name) -> str len(response.json()["value"]) > 0 and "id" in response.json()["value"][0] ): - return response.json()["value"][0]["id"] + # find the site with the specified name + for site in response.json()["value"]: + if site["name"].lower() == sharepoint_site_name.lower(): + return site["id"] + + raise ValueError( + f"The specified sharepoint site {sharepoint_site_name} is not found." + ) else: raise ValueError( f"The specified sharepoint site {sharepoint_site_name} is not found." diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml index f872bc58136f8..34d5908ae8e38 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml @@ -29,7 +29,7 @@ license = "MIT" maintainers = ["arun-soliton"] name = "llama-index-readers-microsoft-sharepoint" readme = "README.md" -version = "0.2.3" +version = "0.2.4" [tool.poetry.dependencies] python = ">=3.8.1,<4.0"