Open stvpwrs opened 1 year ago
So I got here after trying to get the drive_item_id
of a folder based on its path because I could not find a correct RequestBuilder that would enable me to do that, only HTTP request templates in the docs.
after digging through and debugging the source it turns out that when they write in the docs of any with_url
methods that
Using this method means any other path or query parameters are ignored
They mean that any request builders that you've invoked before this method will be invalidated and you have to build your request url completely in this raw_url
string from staring with "http" to the last char
For me this was completely counter-intuitive and also tried as you did first.
Here's what I did:
async def get_drive_item_by_path(path: str) -> DriveItem | None:
from msgraph.generated.drives.item.items.item.drive_item_item_request_builder import (
DriveItemItemRequestBuilder,
)
url: str = (
f"{graph_client.request_adapter.base_url}"
f"/drives/{driver_data['drive_id']}/root:{path}"
)
# We need to use the DriveItemItemRequestBuilder with a custom URL
# because it doesn't implement the get_by_path method
drive_request = DriveItemItemRequestBuilder(
azure_module.graph_client.request_adapter, url
)
response: DriveItem | None = await drive_request.get()
return response
Reporting an Issue or Missing Feature
When attempting to get a SharePoint site a Kiota authentication error is thrown.
Expected behavior
A site object should be returned.
Actual behavior
The following error is thrown:
Steps to reproduce behavior
Versions
Operating system/environment?