sreeise / graph-rs-sdk

Microsoft Graph API Client And Identity Platform Client in Rust
MIT License
114 stars 30 forks source link

`item_by_path` not working as intended on v2.0.0-beta.0 #460

Closed samvv closed 10 months ago

samvv commented 10 months ago

Describe the bug graph.drive(DRIVE_ID).item_by_path(PATH) is not formatting the URL appropriately.

To Reproduce Steps to reproduce the behavior:

let graph = Graph::from(&confidential_client_application);
let res = graph
    .drive("<MY_DRIVE>")
    .item_by_path("/path/to/some/folder")
    .list_children()
    .send();

This generates the following URI:

/v1.0/drives/<MY_DRIVE>/root/path/to/some/folder/children

While it should generate the following URI:

/v1.0/drives/<MY_DRIVE>/root:/path/to/some/folder:/children

Error code is a 400 invalid request or 404 not found.

Expected behavior A successful response when PATH points to an existing file or folder on the drive.

Desktop:

Additional context Trying to make a backup service for a client using this crate.

buhaytza2005 commented 10 months ago

Hi,

I'm using this crate for a similar project and if I remember correctly you have to add the colons yourself.

I believe the download file example specifies this in the instructions download file example

Hope this helps!

samvv commented 10 months ago

Whoops, if it's in the examples, then this is not a bug! Thanks for the info, that is indeed how I do it right now.

sreeise commented 10 months ago

Whoops, if it's in the examples, then this is not a bug! Thanks for the info, that is indeed how I do it right now.

Thanks @buhaytza2005 for clearing that up.

@samvv Sorry about that. It is actually something the sdk did do for you in a earlier version but it ended up just better for the caller to specify due to differences whether its for the root folder (top-most level folder) vs any other folder or file. For root you have to specify ":/" if you just want the metadata for only the root and for nested folders its ":/folder:". I think there were other issues but I can't remember off the top of my head right now.

There are ways to do it through different checks of couse. Id be interested to see what Microsoft's SDKs are currently doing for path based items to be honest. Possibly a feature to look at in the future.