(503) server unavailable when trying to download items from a share

  • 1
  • Question
  • Updated 3 months ago
Hi,

I got following error while downloading items from a share : 'The remote server returned an error: (503) Server Unavailable'. Here are the steps to reproduce the issue:

1. Create share (ShareType : 'Send').
2. Get the download url from the response of 'Downloads Share Items' request (https://account.sf-api.com/sf/v3/Shares(shareid)/Download)
3. Downloads the resource as a Byte array from the 'downloadurl' using WebClient .

using (var client = new WebClient())
                {
                    byte[] data = client.DownloadData(downloadUri);
                }

DownloadData method returns the error. Do you have any solution for this?

Thanks,
Niyas
Photo of Muhammed Niyas

Muhammed Niyas

  • 25 Posts
  • 2 Reply Likes

Posted 7 months ago

  • 1
Photo of Su Sai

Su Sai, Employee

  • 16 Posts
  • 3 Reply Likes
What is the error message or error codes?
Photo of Muhammed Niyas

Muhammed Niyas

  • 25 Posts
  • 2 Reply Likes
Hi,

Here is the error message:

The remote server returned an error: (503) Server Unavailable.
[StackTrace] -    at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)......




The issue occurred when I immediately downloaded the file using downloadURL. I tried adding some delay in between step #2 and #3 and it worked. 

I think there is some time taken for preparing the download. Is there any way to know when the file is ready for download? I mean any API to check the status before calling the download URL?

Thanks,
Niyas
(Edited)
Photo of Muhammed Niyas

Muhammed Niyas

  • 25 Posts
  • 2 Reply Likes
Su,

For large files, I got 'DownloadUrl' and 'DownloadPrepStatusURL' from API response.  There is only 'DownloadUrl' in the response for small files.

Here is the download URL for a share : 
https://******.sharefile.com/download.ashx?dt=*********&h=*******************

Can I create the download prepare status URL by replacing the text  'download' by 'downloadprepstatus' in the 'download URL'? 

like:
https://******.sharefile.com/downloadprepstatus.ashx?dt=*********&h=*******************

If yes, I can use the above url to check the status and start download once the status is 100.

Also could you please explain the parameters 'dt' and 'h' in the url?


Thanks,
Niyas
Photo of Su Sai

Su Sai, Employee

  • 16 Posts
  • 3 Reply Likes
Yes, you can use 'DownloadPrepStatusURL' in the API response to check the status. The value is percentage.
Photo of Muhammed Niyas

Muhammed Niyas

  • 25 Posts
  • 2 Reply Likes
Hi,

For small files , we didn't get the 'DownloadPrepStatusURL' in the API response. Please let me know if you need any additional information.

Thanks,
Niyas