shareplum
shareplum copied to clipboard
_Folder Class Creates Folder If It Does Not Exist
Just letting everyone know that the _Folder class will actually start generating folders if it does not exist. So I ended up generating ~20 folders by accident...Woops! To fix this I extended the class so it would send a get request rather than post
class ExtendedFolder(folder._Folder):
def _create_folder(self):
update_data = {}
update_data['__metadata'] = {'type': 'SP.Folder'}
update_data['ServerRelativeUrl'] = self.folder_name
body = json.dumps(update_data)
url = self.site_url + f"/_api/web/folders"
headers = {'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json;odata=verbose',
'X-RequestDigest': self.contextinfo['FormDigestValue']}
response = request_helper.get(self._session, url=url, headers=headers, data=body, timeout=self.timeout)
return response.json()
just an fyi because the folder names can change in my use case
Thanks - I've just been caught out by this!
Hey, can you explain me changes on the file folder.py please ? just add your code ?
Thank you f-thomson jeremyfox36