This DTO has been deprecated as part of the Relativity Services API (RSAPI) Deprecation and is no longer supported. For more information and alternative APIs, see RSAPI deprecation process.
Download files from Relativity Dynamic Objects
You can use the GET method to download a file from a Relativity Dynamic Object (RDO). You don't need to provide a body for this request, and the response contains JSON only when the request fails.
This sample URL illustrates how to identify the file that you want to download.
Copy
http://localhost/Relativity.REST/Workspace/1015349/Example%20RDO/1041611/Fields/File%20Field/File
This code sample shows how to use the GET method on an RDO and then read the file.
Copy
// Set up the client.
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://localhost/");
// Set the required headers.
httpClient.DefaultRequestHeaders.Add("X-CSRF-Header", "-");
httpClient.DefaultRequestHeaders.Add("Authorization", "Basic c2FtcGxlYWRtaW5AcmVsYXRpdml0eS5yZXN0OlMwbTNwQHNzdzByZA==");
//Call the GET method on an RDO. It is named "Example RDO" in this sample.
string url = "Relativity.REST/Workspace/1015349/Example%20RDO/1041611/Fields/File%20Field/File";
HttpResponseMessage response = httpClient.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
try
{
// Read the file.
Stream resultStream = response.Content.ReadAsStreamAsync().Result;
// The ContentDisposition header contains the name of the file name
// that you are donwloading.
string fileName = response.Content.Headers.ContentDisposition.FileName;
using (var fileStream = File.Create("C:\\" + fileName))
{
resultStream.CopyTo(fileStream);
}
}
catch(Exception)
{
// An error occurred while the system was attempting to read and
// save the file locally.
// Handle the exception.
}
}
else
{
string resultString = response.Content.ReadAsStringAsync().Result;
// Parse the falure result with Json.NET.
JObject resultObject = JObject.Parse(resultString);
}