get_sp_item() wraps the get_item method for ms_drive objects and
returns a ms_drive_item object by default. Additional parameters in ...
are passed to get_sp_drive().
Use get_sp_item_properties() to get the item properties instead. Setting
properties = TRUE returns the same properties, but only
get_sp_item_properties() can include the document library column values
(fields) for the item.
If path or item_url is a SharePoint URL for a file or folder (e.g. a
link from "Copy link" in SharePoint, a document URL, or a document library
URL) and item_id, drive_name, drive_id, and drive aren't supplied,
get_sp_item() gets the item with the Microsoft Graph shares API. This works for
items in any document library and for links to items that have been moved.
The Microsoft Graph login uses site, site_url, or the site in the URL.
If the shares API request fails, the site, drive, and path or item ID are
parsed from the URL instead.
Usage
get_sp_item(
path = NULL,
item_id = NULL,
item_url = NULL,
...,
drive_name = NULL,
drive_id = NULL,
drive = NULL,
site_url = NULL,
properties = FALSE,
as_data_frame = FALSE,
call = caller_env()
)Arguments
- path
A SharePoint file URL or the relative path to a file located in a SharePoint drive. If input is a relative path, the string should not include the drive name. If input is a shared file URL, the text "Shared " is removed from the start of the SharePoint drive name by default. If file is a document URL, the
default_drive_nameargument is used as thedrive_nameand theitem_idis extracted from the URL.- item_id
A SharePoint item ID passed to the
itemidparameter of theget_itemmethod forms_driveobjects.- item_url
A SharePoint item URL used to parse the item ID, drive name, and site URL.
- ...
Arguments passed on to
get_sp_drivedrive_name,drive_idSharePoint Drive name or ID passed to
get_drivemethod for SharePoint site object.drive_urlA SharePoint Drive URL to parse for a Drive name and other information. If
drive_nameis a URL, it is used asdrive_url.default_drive_nameDrive name string used only if input is a document URL and drive name is not part of the URL. Defaults to
getOption("sharepointr.default_drive_name", "Documents")cacheIf
TRUE, cache drive to a file usingcache_sp_drive().refreshIf
TRUE, get a new drive even if the existing drive is cached as a local option. IfFALSE, use the cachedms_driveobject if it exists.cache_fileFile name for cached drive or site. Default
NULL.siteA
ms_siteobject. Ifsiteis supplied,site_url,site_name, andsite_idare ignored.overwriteIf
TRUE, replace the existing cached object named bycache_filewith the new object. IfFALSE, error if a cached file with the samecache_filename already exists.
- drive_name, drive_id
SharePoint drive name or ID.
- drive
A
ms_driveobject. If drive is supplied,drive_name,site_url, and any additional parameters passed to...are ignored.- site_url
A SharePoint site URL in the format "https://[tenant name].sharepoint.com/sites/[site name]". Any SharePoint item or document URL can also be parsed to build a site URL using the tenant and site name included in the URL.
- properties
If
TRUE, use theget_item_propertiesmethod and return item properties instead of the item.- as_data_frame
If
TRUE, return a data frame. IfFALSE(default), return ams_itemorms_item_propertiesobject.- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.
Value
A ms_drive_item object (or a list of item properties if
properties = TRUE), or a 1 row data frame if as_data_frame = TRUE.
Examples
sp_item_url <- "<SharePoint item url>"
if (is_sp_url(sp_item_url)) {
get_sp_item(
item_url = sp_item_url
)
}