Skip to content

Moving files between Sharepoint folders cause issues only sometimes #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
surajram1 opened this issue Jun 16, 2020 · 2 comments
Open
Labels

Comments

@surajram1
Copy link

surajram1 commented Jun 16, 2020

As I attempt to move files from one folder to a sub-folder - similar to this example below, I find that this works for certain excel files but not for some others in the same folder. I can't seem to find any pattern in file names or size for this.

ctx = ClientContext(site_url, ctx_auth)
# get a source file located in library 'Shared Documents'
source_file = ctx.web.get_file_by_server_relative_url("/teams/Team123/Shared Documents/Guide.docx")
# move a file into sub folder called 'Archive'
source_file.moveto("/teams/Team123/Shared Documents/Archive/Guide.docx", 1)
# execute a query
ctx.execute_query()

The error I receive is ClientRequestException: (None, None, "401 Client Error: Unauthorized for url:..... which is weird as I authenticated through client ID and Secret and all the files are in the same folder but only some files have this issue.

I find when I was using Sharepy, these files are moved without issue when I call the files by 'GetFileById' whereas in office365 library, I am taking file by relative url (get_file_by_server_relative_url). I didn't find a way to take file by ID here. Can someone help with this

@vgrem vgrem added the question label Jun 16, 2020
@erfannariman
Copy link

Were you able to solve this? I get the same error, but for any file.

@thomasfrederikhoeck
Copy link

I think this is related to the error in #319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants