I am using the standard System.Net.WebClient to download files from ShareFile but running into an issue.

  • 1
  • Question
  • Updated 2 weeks ago
I am using the standard System.Net.WebClient to download files from ShareFile but running into an issue. Every file type is returned as an XML file. Here is my code:

$urls += "https://carlwebster.sharefile.com/d-s5e1f2589c5c4bb8a";
$outputs += "$ScriptDir\Get-CAInfo_Signed.ps1"
$wc = New-Object System.Net.WebClient
$cnt = -1
ForEach($url in $urls)
{
$cnt++
$Error.Clear()
Try {$wc.DownloadFile($url, $outputs[$cnt])}
Catch {}
$e = $Error[0]
If($null -ne $e -and $e.Exception.ToString().Contains("Exception calling "))
{
Write-Host "Unable to automatically download required file." -ForegroundColor Red
Break
}
}
I ran into the same problem with Dropbox but it was easily fixed. I had to change the Dropbox from url "https://www.dropbox.com/s/sj0vkiq9u92u8mq/Get-CAInfo_Signed.ps1?dl=0" to "https://www.dropbox.com/s/sj0vkiq9u92u8mq/Get-CAInfo_Signed.ps1?raw=1" .

Is there something that can be changed on the ShareFile download link to make it stop converting every file to XML?

Thanks


Webster
Photo of Carl Webster

Carl Webster

  • 4 Posts
  • 0 Reply Likes

Posted 2 weeks ago

  • 1
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 48 Posts
  • 5 Reply Likes
Hi Carl,

We don't convert any files to xml. The problem is that your download url is actually a share link, so you're either downloading a server error message or a website.
You can verify this by going to the url in your browser; it should open up the ShareFile web app instead of downloading a file.

To get the download url you'll need to use our rest API to get it (or preferably make use of our powershell sdk https://support.citrix.com/article/CTX207460)