I am uploading a file to SharePoint successfully using the office365-rest-api, but when I come to set the metadata in the SharePoint columns I'm getting an error. This only happens when I have a file with a very long filename (around 180 characters). Files with short filenames work fine.
My code is
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file_system_object_type import FileSystemObjectType
from office365.sharepoint.files.file_creation_information import FileCreationInformation
targetFolderUrl = ctx.web.ensure_folder_path(SP_Location).execute_query()
targetFile = targetFolderUrl.upload_file(fileName, fileContent)
ctx.execute_query()
listItem=targetFile.listItemAllFields
listItem.set_property('COMMITTEE','SM_Team')
listItem.update()
ctx.execute_query(
The error I'm getting is :-
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://verylongurl+filename/listItemAllFields
Is there a limit on the number of characters the url +filename is? If so, how come it uploads the file ok, but only fails when I set the columns?