fix: URL encode folder path in List-XlsFiles function

This commit is contained in:
Bobby Abellana (aider) 2025-02-21 09:26:32 -08:00
parent 4a3c1bb26e
commit 5194dc0198

View File

@ -72,8 +72,12 @@ function List-XlsFiles {
# Get the folder ID first
# Construct the correct URI for the folder
# Remove the /sites/tax/Shared Documents part from the folder path
$relativePath = $folderPath.Replace("/sites/tax/Shared Documents/", "")
$folderUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:$($relativePath)"
$relativePath = $folderPath.Replace("/sites/tax/Shared Documents/", "").TrimStart("/")
# URL encode the relative path
$encodedPath = [System.Web.HttpUtility]::UrlEncode($relativePath)
$folderUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:/$encodedPath"
$script:txtStatus.Text += "Folder URI: $folderUri`n"
try {
$folderItem = Invoke-MgGraphRequest -Method GET -Uri $folderUri -ErrorAction Stop