Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
copy_folder.py example doesn't seem to work for SharePoint Online
Used copy_to, move_to methods to copy or move files from one folder to another in the same directory. Just doesn't seem to work.
With the target folder already created, there is no error as such if we are executing the script below:
#siteUrl="<tenant_name>.sharepoint.com/sites/<site_collection_name>/" #app has full control to this site collection
context_auth = AuthenticationContext(url=site_url)
context_auth.acquire_token_for_app(client_id=app_principal['client_id'], client_secret=app_principal['client_secret'])
ctx = ClientContext(site_url, context_auth)
web = ctx.web
ctx.load(web)
folder_name=jr_number
status_name=jr_status
new_folder_name = folder_name+"_"+status_name
temp_folder = web.get_folder_by_server_relative_url(SP_DOC_LIBRARY+'/'+folder_name)
temp_folder.move_to(SP_DOC_LIBRARY+'/'+new_folder_name).get().execute_query()