Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
308 stars 41 forks source link

`drv$list_shared_items()` returns list of `ms_object` and not list of `ms_drive_items` #206

Open mstackhouse opened 4 months ago

mstackhouse commented 4 months ago

Currently I'm trying to access shared a shared folder, so in order to find the shared folder item I'm using the method drv$list_shared_items(). The list that's returned is a list of ms_object objects.

Prior to version, I could use that item directly to access files from within the shared folder using folder_item$get_item("path"), but now that the items are classed as ms_object the get_item() method is not available.

In the documentation, it states:

Because of how the Graph API handles access to shared items linked in the root, you cannot directly access subitems of shared folders via the drive get_item method, like this: drv$get_item("shared_folder/path/to/file"). Instead, get the item into its own object, and use its get_item method: drv$get_item("shared_folder")$get_item("path/to/file")

Unfortunately I can't get this to work, because:

mstackhouse commented 3 months ago

I think you just sent this via a reply to the email, but just an FYI this didn't update as a comment on the GitHub issue itself: https://github.com/Azure/Microsoft365R/issues/206

On Tue, Apr 2, 2024 at 2:51 PM dcomputing @.***> wrote:

The public version 2.4.0 does not return a list of ms_drive_items as per NEWS: The list_shared_items()/list_shared_files() method for drives now always returns a list of drive item objects https://cran.r-project.org/web/packages/Microsoft365R/news/news.html http://url

As seen in the 2.4.0 version of the function below, it returns a vector based on the drive item objects and this causes all code depending on a list of drive item objects from list_shared_items() to fail since drive item object functions are no longer available. Whatever happened to issue

189 https://github.com/Azure/Microsoft365R/issues/189 which is

supposed to fix this problem?

list_shared_items=function(allow_external=TRUE, filter=NULL, n=Inf, pagesize=1000, info=NULL) { if(!is.null(info) && info != "items") warning("Ignoring 'info' argument, returning a list of drive items")

opts <- list(`$top`=pagesize)
if(allow_external)
    opts$allowExternal <- "true"
if(!is.null(filter))
    opts$`filter` <- filter
children <- self$do_operation("sharedWithMe", options=opts, simplify=FALSE)

# get file list as a data frame, or return the iterator immediately if n is NULL
out <- extract_list_values(self$get_list_pager(children), n)
names(out) <- sapply(out, function(obj) obj$properties$name)
out

}

— Reply to this email directly, view it on GitHub https://github.com/Azure/Microsoft365R/issues/206#issuecomment-2032816799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPO7L6UPIYYQC7O6RPXMPTY3L427AVCNFSM6AAAAABFJS3SPKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZSHAYTMNZZHE . You are receiving this because you authored the thread.Message ID: @.***>

dcomputing commented 3 months ago

I think you just sent this via a reply to the email, but just an FYI this didn't update as a comment on the GitHub issue itself: #206

Sorry, I deleted the comment I had posted. The code I was dealing with depended on the previous data frame table that had the properti isDir set. I have yet to work out how to handle 2.4.0's list_share_items output. I thought I could call the ms_drive_item's is_folder function but as you say, it is not a list of ms_drive_items.