Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
318 stars 45 forks source link

get_subsite() not available #115

Closed berlioz5 closed 1 year ago

berlioz5 commented 2 years ago

Hi - i am trying to access a subsite inside a SharePoint library. after review, I found the below snippet from the OneDrive and SharePoint vignette. however, when I try to use get_subsite() it doesn't seem to be a valid method. does anyone have experience accessing subsites or can someone point me to what i'm doing wrong? i've had no probem accessing sharepoint root sites and drives. just seem to be having this issue with subsites.

vignettes/od_sp.Rmd

Finally, you can retrieve subsites with list_subsites() and get_subsite(). These also return SharePoint site objects, so all the methods above are available for a subsite.

berlioz5 commented 2 years ago

@hongooi73 is there any chance you can take a look at this? I would really appreciate it. you've really done amazing work with this package.

hongooi73 commented 2 years ago

Can you provide a sample of the failing code? What error are you getting?

berlioz5 commented 2 years ago

Hi, below is some code. apologies that its heavily redacted. I am getting an error when trying to use the described get_subsite() method. and honestly, i cant even see that as a method per the output of the call to the main site, so I'm not sure what's going on or if gets_subsite() actually exists.

is there a different way to access the subsite that i'm unaware of? semi-related, @hongooi73, im wondering if you do consulting work. if so what's the best way to get in contact.

Thanks


library(AzureGraph)
library(Microsoft365R)

sp_site <- get_sharepoint_site(site_url =   "https://redacted.sharepoint.com/sites/redactedsitename")

sp_site

<Sharepoint site 'redacted Main Hub'>
  directory id: redacted.sharepoint.com,redacted
  web link: https:/redacted.sharepoint.com/sites/redacted
  description: redacted description
---
  Methods:
    delete, do_operation, get_drive, get_group, get_list, get_list_pager, get_lists, list_drives, list_subsites, sync_fields, update

> f <- sp_site$list_subsites()
> f
[[1]]
<Sharepoint site 'redacted'>
  directory id: redacted
  web link: https://redacted.sharepoint.com/sites/redacted/redactedsubsite
  description: redacted
---
  Methods:
    delete, do_operation, get_drive, get_group, get_list, get_list_pager, get_lists, list_drives, list_subsites, sync_fields, update

[[2]]
<Sharepoint site 'redacted'>
  directory id: redacted
  web link: https://redacted.sharepoint.com/sites/redacted/redactedsubsite
  description: redacted
---
  Methods:
    delete, do_operation, get_drive, get_group, get_list, get_list_pager, get_lists, list_drives, list_subsites, sync_fields, update

## attempts at get_subsite

> f <- sp_site$get_subsite("redacted subsite_name")
Error: attempt to apply non-function
hongooi73 commented 2 years ago

Looks like for whatever reason, I forgot to implement get_subsite. However, you don't actually need it; you can just use the result of list_subsites. That's just a list of objects representing all the subsites of your site.

sp_site$list_subsites()[[1]]  # 1st subsite
sp_site$list_subsites()[[2]]  # 2nd subsite
hongooi73 commented 2 years ago

And yes, I'm available for consulting! You can email me at the package maintainer address: hongooi73 (at) gmail.com.

hongooi73 commented 2 years ago

Actually, the reason I didn't implement get_subsite is because there's no documented API call for this. Instead, try using the regular get_sharepoint_site function, and pass it the URL for your subsite.

Disclaimer: I don't have access to a business MS365 sub right now, so I can't test this.

berlioz5 commented 2 years ago

thank you! that worked. I might reach out in the next few weeks. I appreciate your help.