1. List item

I am using python 3.10 using Office365-REST-Python-Client==2.4.1

my code attempts to move a file from sharepoint

def get_file(ctx: ClientContext, name: str) -> File:
result = None
try:
    file: File = ctx.web.get_file_by_server_relative_url(name)
    ctx.load(file)
    ctx.execute_query()
    result = file

except ClientRequestException as e:
    print(e)
finally:
    return result

    file_from: File = get_file(ctx, file_to_move)
    file_from.moveto(folder_to, True)
    ctx.execute_query()

I have checked the validity of the file and have gotten its unique id

the File.moveto call signature takes as first parameter:

{"newurl": new_relative_url,"flags": flag}

i pass to move the file to a directory called Documents/.../inventory/error. The directory exist. I get an error.

i pass to move the file to a directory called Documents/.../inventory/error/name. I want the file to be named 'name'. I get an error.

i pass to move the file to a directory called sites/...Documents/.../inventory/error/name. I want the file to be named 'name'. I get an error.

('-1, Microsoft.SharePoint.Client.InvalidClientQueryException', 'Input string was not in a correct format.', "400 Client Error:

what should the format of the first parameter and second parameter to File.moveto be?

0

There are 0 answers