Skip to content

Commit

Permalink
chore: improve share point get sitename (#14411)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanuelCampos authored Jun 26, 2024
1 parent a26682e commit 1bbb2f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1bbb2f6

Please sign in to comment.