From 97ce4230ba3f1c470d2426ac28a7d4d551bc4e77 Mon Sep 17 00:00:00 2001 From: Raul Villar Ramos Date: Thu, 18 Oct 2018 13:50:47 +0200 Subject: [PATCH] Small Fix (Upload) #I add manually a folder named "test" $ReportPortalUri = 'ServerURL/reports' Write-Host "Upload an item..." $uploadItemPath = 'C:\test\test.rdl' # single File $catalogItemsUri = $ReportPortalUri + "/api/v2.0/CatalogItems" $bytes = [System.IO.File]::ReadAllBytes($uploadItemPath) $payload = @{ "@odata.type" = "#Model.Report"; "Content" = [System.Convert]::ToBase64String($bytes); "ContentType"=""; "Name" = 'newNameOfthefile'; "Path" = '/folterToSave'; } | ConvertTo-Json Invoke-WebRequest -Uri $catalogItemsUri -Method Post -Body $payload -ContentType "application/json" -UseDefaultCredentials | Out-Null #---------------------------- #Download example working $ReportPortalUri = 'URLserver/reports' Write-Host "Download an item..." $downloadPath = 'C:\download\example.rdl' $catalogItemsApi = $ReportPortalUri + "/api/v2.0/CatalogItems(Path='/test/example')/Content/$value" #You need to put exact route to avoid error. $url = [string]::Format($catalogItemsApi, $item) $response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials [System.IO.File]::WriteAllBytes($downloadPath, $response.Content) #---------------------- #delete. $ReportPortalUri = 'ServerUrl/reports' Write-Host "Delete an item..." $url = $ReportPortalUri + "/api/v2.0/CatalogItems(Path='/test')" #this will delete the full folder Invoke-WebRequest -Uri $url -Method Delete -UseDefaultCredentials | Out-Null --- .../{powershellSamples.ps1 => powershellSamplesFix.ps1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename APISamples/powershell/{powershellSamples.ps1 => powershellSamplesFix.ps1} (100%) diff --git a/APISamples/powershell/powershellSamples.ps1 b/APISamples/powershell/powershellSamplesFix.ps1 similarity index 100% rename from APISamples/powershell/powershellSamples.ps1 rename to APISamples/powershell/powershellSamplesFix.ps1