@@ -249,6 +249,17 @@ def get_file_by_server_relative_url(self, url):
249249 ResourcePathServiceOperation ("getFileByServerRelativeUrl" , [url ], self .resource_path )
250250 )
251251
252+ def get_file_by_server_relative_path (self , decoded_url ):
253+ """Returns the file object located at the specified server-relative path.
254+ Prefer this method over get_folder_by_server_relative_url since it supports % and # symbols in names
255+
256+ :type decoded_url: str
257+ """
258+ return File (
259+ self .context ,
260+ ResourcePathServiceOperation ("getFileByServerRelativePath" , {"DecodedUrl" : decoded_url }, self .resource_path )
261+ )
262+
252263 def get_folder_by_server_relative_url (self , url ):
253264 """Returns the folder object located at the specified server-relative URL.
254265 :type url: str
@@ -258,6 +269,19 @@ def get_folder_by_server_relative_url(self, url):
258269 ResourcePathServiceOperation ("getFolderByServerRelativeUrl" , [url ], self .resource_path )
259270 )
260271
272+ def get_folder_by_server_relative_path (self , decoded_url ):
273+ """Returns the folder object located at the specified server-relative URL.
274+ Prefer this method over get_folder_by_server_relative_url since it supports % and # symbols
275+ Details: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/supporting-and-in-file-and-folder-with-the-resourcepath-api
276+
277+ :type decoded_url: str
278+ """
279+ params = {"DecodedUrl" : decoded_url }
280+ return File (
281+ self .context ,
282+ ResourcePathServiceOperation ("getFolderByServerRelativePath" , params , self .resource_path )
283+ )
284+
261285 def ensure_folder_path (self , path ):
262286 """
263287 Ensures a nested folder hierarchy exist
0 commit comments