Srini Srini - 11 days ago 4x
C# Question

Download File from AutoDesk Vault (Vault 2015 SDK) with c# code giving error

I am trying to download a file from Vault (Vault 2015 SDK) using code. Tried the exact same approach as mentioned here:
but getting the error "The request failed with HTTP status 404: Not Found" while executing the respective line of code for downloading the file.

Please find below my sample code:

using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Connectivity.WebServices;

UserPasswordCredentials login = new UserPasswordCredentials("servername",
"myVault", "username", "Password", true);
using (WebServiceManager serviceManager = new WebServiceManager(login))
Autodesk.Connectivity.WebServices.Folder folder = serviceManager.DocumentService.GetFolderByPath("$/Myfolder");
Autodesk.Connectivity.WebServices.File[] files = serviceManager.DocumentService.GetLatestFilesByFolderId(folder.Id, false);
if (files != null && files.Any())
foreach (Autodesk.Connectivity.WebServices.File file in files)
//Sample code to download the files
string localPath = AppDomain.CurrentDomain.BaseDirectory;
Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
var FileDownloadTicket = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { file.Id });
FilestoreService fileStoreService = new FilestoreService();
var fileBytes = fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
System.IO.File.WriteAllBytes(localPath, fileBytes);

Getting the error at fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
I am able to download the file manually but not programatically. What am i doing wrong ?
Also it would be great if i can get some sample code to download a file based on the metadata.



I modified

FilestoreService fileStoreService = new FilestoreService()


FilestoreService fileStoreService = serviceManager.FilestoreService

in the code snipped posted in the question and it worked.