>  >  

Help on the REST API for Storage

 
This page describes how to interact with the repository through its RESTful API.
Please note that you can also use dedicated command-line tools.

Folder

List a Folder Content

You can list the content of a folder to retrieve folders and files via an HTTP GET request.
https://services.open.xerox.com/Folder.svc/rest/Folder/SubFolder returns an XML result like this:

<Folder Name="SubFolder" Path="Folder/SubFolder">
  <Folders>
    <Folder Name="SubFolder2" Path="Folder/SubFolder/SubFolder2"
    ModificationDate="2009-07-30T16:55:30.9263625+02:00" IsEmpty="true"/>
  </Folders>
  <Files>
    <File Name="TestFile1.txt" Path="Folder/SubFolder/TestFile1.txt"
    ModificationDate="2009-07-30T16:57:07.4689122+02:00" Size="12"/>
  </Files>
</Folder>

This result shows that the Folder/SubFolder folder contains one empty folder named "SubFolder2" and one file named "TestFile1.txt" with a size of 12 bytes.
Please note that this request can be made with your browser.

Create a new folder

You can create a new folder via an HTTP POST request on the parent folder: https://services.open.xerox.com/Folder.svc/rest/Folder/SubFolder
You need to submit an XML file with the request to fill the folder name. The XML file needs to be like this:

<Folder Name='NewFolder'></Folder>

C# Example:

HttpWebRequest requestGet = WebRequest.Create(FOLDER_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "POST";
requestGet.ContentType = "text/xml";
StreamWriter sw = new StreamWriter(requestGet.GetRequestStream());
sw.Write("<Folder Name='NewFolder'></Folder>");
sw.Close();

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;
		

 

Delete a folder

You can delete a folder (if one exists) via an HTTP DELETE request on the folder: https://services.open.xerox.com/Folder.svc/rest/Folder/SubFolder

C# Example:

HttpWebRequest requestGet = WebRequest.Create(FOLDER_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "DELETE";
requestGet.ContentType = "text/xml";

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;

 

 

Rename folder

You can rename a folder (if one exists) via an HTTP PUT request on the folder: https://services.open.xerox.com/Folder.svc/rest/Folder/SubFolder
You need to submit an XML file with the request to fill the folder name. The XML file needs to be like this:

<Folder Name='NewFolderName'></Folder>

C# Sample:

HttpWebRequest requestGet = WebRequest.Create(FOLDER_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "PUT";
requestGet.ContentType = "text/xml";
StreamWriter sw = new StreamWriter(requestGet.GetRequestStream());
sw.Write("<Folder Name='NewFolderName'></Folder>");
sw.Close();
			
// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;
		

 

File

Retrieve file content

You can retrieve the file content via an HTTP GET request on https://services.open.xerox.com/File.svc/rest/Folder/SubFolder/TestFile1.txt

C# Example:

WebClient webClient = new WebClient();
webClient.Headers.Add("Content-Type", "text/plain");
webClient.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", TOKEN);
webClient.DownloadFile(FILE_URL, FILE_CONTENT);

WGET Example:

wget --no-check-certificate FILE_URL

CURL Example:

curl -k -o FILE_CONTENT FILE_URL
curl -k -H "Authorization:WRAP access_token=""TOKEN""" -o FILE_CONTENT FILE_URL

 

Upload a new file

You can upload a new file via an HTTP POST request on the file: https://services.open.xerox.com/File.svc/rest/Folder/SubFolder/TestFile1.txt

C# Example:

WebClient webClient = new WebClient();
webClient.Headers.Add("Content-Type", "text/plain");
webClient.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
webClient.UploadData(FILE_URL, FILE_CONTENT);

CURL Example:

curl -k -H "Content-Type:text/plain" -H "Authorization:WRAP access_token=""TOKEN""" -X POST -T FILE FILE_URL

 

Update file content

You can update file content via an HTTP PUT request on the file. https://services.open.xerox.com/File.svc/rest/Folder/SubFolder/TestFile1.txt

C# Example:

HttpWebRequest requestGet = WebRequest.Create(FILE_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "PUT";
requestGet.ContentType = "text/plain";
StreamWriter sw = new StreamWriter(requestGet.GetRequestStream());
sw.Write(FILE_CONTENT);
sw.Close();

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;
		

CURL Example:

curl -k -H "Content-Type:text/plain" -H "Authorization:WRAP access_token=""TOKEN""" -T FILE FILE_URL

 

Delete a file

You can delete a file (if one exists) via an HTTP DELETE request on the file: https://services.open.xerox.com/File.svc/rest/Folder/SubFolder/TestFile1.txt

C# Example:

HttpWebRequest requestGet = WebRequest.Create(FILE_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "DELETE";
requestGet.ContentType = "text/xml";

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;

 

 

Metadata

List Metadata

You can list file or folder metadata via an HTTP GET request.
https://services.open.xerox.com/Metadata.svc/rest/Folder/SubFolder/TestFile.txt returns an XML result like this:

 

<?xml version="1.0" encoding="utf-16"?>
<Metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <Metadatum Name="Metadata1" Type="STRING">Value1</Metadatum>
   <Metadatum Name="Metadata2" Type="STRING">Value2</Metadatum>
   <Metadatum Name="Metadata2" Type="BINARY">DQ0KUGluZ2luZyAxMjcuMC4wLjEgd2l0aCA</Metadatum>
</Metadata>

 

Add a new metadatum

You can create a metadatum (String or Binary) via an HTTP POST request on https://services.open.xerox.com/Metadata.svc/rest/Folder/SubFolder/TestFile.txt
You need to submit an XML file withthe request to fill the metadatum name and value. You need to specify the type of the Metadata (STRING (by default) or BINARY). For Binary metadata, please note that you need to encode the value as Base64. The XML file needs to be like this:

<Metadatum Name="Metadatum Name">Metadatum Value</Metadatum>
<Metadatum Name="Metadatum Name" Type="BINARY">ZyAxMjcuMC4wLjEgd2l0aCA</Metadatum>

C# Example:

HttpWebRequest requestGet = WebRequest.Create(METADATA_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "POST";
requestGet.ContentType = "text/xml";
StreamWriter sw = new StreamWriter(requestGet.GetRequestStream());
sw.Write("<Metadatum Name=\"Metadatum Name\">Metadatum Value</Metadatum>");
sw.Close();

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;
		

 

Delete a metadatum

You can delete a metadatum (if one exists) via an HTTP DELETE request on https://services.open.xerox.com/Metadata.svc/rest/Folder/SubFolder/TestFile1.txt?Name=Name

C# Example:

HttpWebRequest requestGet = WebRequest.Create(METADATA_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "DELETE";
requestGet.ContentType = "text/xml";

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;

 

 

Delete all metadata

You can delete all metadata via an HTTP DELETE request without key name on https://services.open.xerox.com/Metadata.svc/rest/Folder/SubFolder/TestFile1.txt

C# Example:

HttpWebRequest requestGet = WebRequest.Create(METADATA_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "DELETE";
requestGet.ContentType = "text/xml";

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;

 

 

Update a metadatum

You can update a metadatum via an HTTP PUT request on https://services.open.xerox.com/Metadata.svc/rest/Folder/SubFolder/TestFile.txt?Name=OldName
You need to submit an XML file with the request to fill the metadatum name and value. You need to specify the type of Metadata (STRING (by default) or BINARY). For Binary metadata, please note that you need to encode the value as Base64. The XML file needs to be like this:

<Metadatum Name="Metadatum Name">Metadatum Value</Metadatum>
<Metadatum Name="Metadatum Name" Type="BINARY">ZyAxMjcuMC4wLjEgd2l0aCA</Metadatum>

C# Example:

HttpWebRequest requestGet = WebRequest.Create(METADATA_URL) as HttpWebRequest;
requestGet.Headers[HttpRequestHeader.Authorization] = String.Format("WRAP access_token=\"{0}\"", token);
requestGet.Method = "PUT";
requestGet.ContentType = "text/xml";
StreamWriter sw = new StreamWriter(requestGet.GetRequestStream());
sw.Write("<Metadatum Name=\"Metadatum Name\">Metadatum Value</Metadatum>");
sw.Close();

// get response from server
HttpWebResponse responseGet = requestGet.GetResponse() as HttpWebResponse;