SharePoint Online Connector
Documentation
Version: 18
Documentation

EndPoint Copy item (File or Folder)


Name

copy_item

Description

Copy an item (File or Folder) to a different location in the same drive or another drive (e.g. different User's drive)

Parameters

Parameter Label Required Options Description
DriveId Source Drive Id YES Specify a drive
ItemId Source File or Folder Id you like to copy YES Specify an item Id you like to copy
TargetFolderId Target Folder Id (e.g. 01R65QTTRxxxxx -OR- root) YES Specify a target folder where item should be copied
SiteId Source Site Id (Optional - Select if different than default site) NO Specify a site
TargetSiteId Target Site Id (Optional - Select if different than source SiteId) NO Specify a site
TargetDriveId Target DriveId (Optional - Select if different than source DriveId) NO Specify a drive
TargetItemName Target Item Name (Optional) NO Specify target item name you like to give after copy operation. Keep it blank if you like to keep same name as source.
SearchType Source Search Type - For UI Only (i.e. Recursive -OR- Non-Recursive) - Default=Recursive) NO
Option Value
Recursive All Files (Keep Blank) - not supported for Application Credentials with Sites.Selected Scope
Non-Recursive / Children All Files (Only for Non-Shared Items) children
Recursive All - For User Creds Only search(q='')
Recursive *.xlsx Files - For User Creds Only search(q='.xls')
Recursive *.csv Files - For User Creds Only search(q='.csv')
Recursive *.json Files - For User Creds Only search(q='.json')
Recursive Custom Extension Files - For User Creds Only search(q='.myext')
NOTE: Not Supported with Application Credentials which uses Sites.Selected Scope. If you do not wish to see files from child folders then use Non-Recursive option. Recursive option has certain limitations (e.g. Only indexed files will appear so it takes time to show up in the list). If you do not see some files listed in the output then use Non-Recursive option (must specify Parent Folder Path in SearchPath property).
SearchPath Source Search Folder (For UI Only - Helps to narrow down File Selection DropDown) - Max 200 Listed NO This parameter is only for UI. Select this to narrow down File List Dropdown. Select Search Folder first and then select File List dropdown to see new File list (found under this selected folder).
TargetSearchType Target Search Type (For UI Only - Default=Recursive - i.e. Blank) NO
Option Value
Recursive All Files (Keep Blank) - For User Creds Only
Non-Recursive / Children - All Files children
If you do not wish to see files from child folders then use Non-Recursive option. Recursive option has certain limitations (e.g. Only indexed files will appear so it takes time to show up in the list). If you do not see some files listed in the output then use Non-Recursive option (must specify Parent Folder Path in SearchPath property).
TargetSearchPath Target Search Folder (For UI Only - Helps to narrow down File Selection DropDown) - Max 200 Listed NO This parameter is only for UI. Select this to narrow down File List Dropdown. Select Search Folder first and then select File List dropdown to see new File list (found under this selected folder).
Prefer Prefer Async Operation (Enable if you get error) NO
Option Value
None
Async (Needed for Large files, Cross Site) respond-async
ConflictBehavior Conflict Behavior (What to do if file exists at target location) NO
Option Value
fail fail
replace replace
rename rename
Default ConflictBehavior is fail if file exists. The conflictBehavior is not supported for OneDrive Consumer. Also it will not fail if TargetItemName same as source file name

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Raw Description
Status DT_WSTR nvarchar(4000) 4000 False

Input Columns

Label Data Type (SSIS) Data Type (SQL) Length Raw Description
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime.

Examples

SSIS

Use SharePoint Online Connector in API Source component to read data or in API Destination component to read/write data:

Copy item (File or Folder) using API Source

SharePoint Online
Copy item (File or Folder)
SSIS API Source - Read from table or endpoint

Copy item (File or Folder) using API Destination

SharePoint Online
Copy item (File or Folder)
SSIS API Destination - Access table or endpoint

ODBC application

Use these SQL queries in your ODBC application data source:

Copy a File or Folder in SharePoint Document Library

This example shows how to copy a file or folder to a different location in SharePoint Document Library (In same Drive or different SharePoint Document Library). It also shows how to use Placeholder Functions to name file daynamically. For example to add timestamp it uses <<yyyy-MM-dd-HH-mm-ss-fff,FUN_NOW>>

SELECT * FROM copy_item
WITH(
	--Source Site (Leave blank for default)
	-- SiteId='xxxx'
	
	--Source Drive
	, DriveId='b!0zqxxxxxxxxxxxxxxxxxxxxxxxx'

	--Source Item you like to copy
	, ItemId='01R65QTTRARZ42C4BN6FF2WOH3AONX4GUW'

	--Target Site (Optional)
	-- SiteId='abc.sharepoint.com,5304daff-xxxxxxxxxx'
	
	--Target Drive Id (Optional): Only needed if copying file to a different Drive (e.g. another User's drive)
	--, TargetDriveId='b!0zqXLXXJh0uxxxxxxxxxxxxxxxxxxxxx'
	
	--Target Folder where item will be copied
	, TargetFolderId='01R65QTTTBPH6V2AP36VD33CYYDXJSNHLN'
	--OR--
	--, TargetFolderId='root'

	--Target item name (Optional) - Only needed if new name needed after copy
	, TargetItemName='new_file_or_folder_name_<<yyyy-MM-dd-HH-mm-ss-fff,FUN_NOW>>.pdf' 

	--,ConflictBehavior='replace' --fail, rename (Ignored if TargetItemName is not supplied)

	--Uncomment Below if you get error. Usually needed for large file or cross site operations
	--, Prefer='respond-async'	
)

SQL Server

Use these SQL queries in SQL Server after you create a data source in Data Gateway:

Copy a File or Folder in SharePoint Document Library

This example shows how to copy a file or folder to a different location in SharePoint Document Library (In same Drive or different SharePoint Document Library). It also shows how to use Placeholder Functions to name file daynamically. For example to add timestamp it uses <<yyyy-MM-dd-HH-mm-ss-fff,FUN_NOW>>

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM copy_item
WITH(
	--Source Site (Leave blank for default)
	-- SiteId=''xxxx''
	
	--Source Drive
	, DriveId=''b!0zqxxxxxxxxxxxxxxxxxxxxxxxx''

	--Source Item you like to copy
	, ItemId=''01R65QTTRARZ42C4BN6FF2WOH3AONX4GUW''

	--Target Site (Optional)
	-- SiteId=''abc.sharepoint.com,5304daff-xxxxxxxxxx''
	
	--Target Drive Id (Optional): Only needed if copying file to a different Drive (e.g. another User''s drive)
	--, TargetDriveId=''b!0zqXLXXJh0uxxxxxxxxxxxxxxxxxxxxx''
	
	--Target Folder where item will be copied
	, TargetFolderId=''01R65QTTTBPH6V2AP36VD33CYYDXJSNHLN''
	--OR--
	--, TargetFolderId=''root''

	--Target item name (Optional) - Only needed if new name needed after copy
	, TargetItemName=''new_file_or_folder_name_<<yyyy-MM-dd-HH-mm-ss-fff,FUN_NOW>>.pdf'' 

	--,ConflictBehavior=''replace'' --fail, rename (Ignored if TargetItemName is not supplied)

	--Uncomment Below if you get error. Usually needed for large file or cross site operations
	--, Prefer=''respond-async''	
)';

EXEC (@MyQuery) AT [LS_TO_SHAREPOINT_ONLINE_IN_GATEWAY];