Script Manager (REST)

Relativity Scripts allow for the execution of SQL scripts in the database(s) backing a Relativity instance. The Relativity Script Manager API exposes endpoints allowing for the programmatic interaction with scripts including:

  • Add script
  • Delete a script
  • Modify a script
  • Retrieve script input parameters
  • Preview a script
  • Import a script
  • Queue a script to run
  • Retrieve status of a script
  • Query action results
  • Export action results
  • Export script report
  • Clean up script results

The service may be used to create a standalone application that manages scripts across multiple environments or among workspaces in a single environment.

Contracts and data models related to the API are contained in the following NuGet packages:

  • Relativity.Services.SDK

You can also use the Script service through the .NET API. For more information, see Script Manager API.

This page contains the following information:

Fundamentals for managing resource pools

Client code sample

public async Task<int> CreateScriptAsync()
{
 
    int scriptID = 0;
    using (Relativity.Services.Interfaces.Script.IScriptManager scriptManager = serviceFactory.CreateProxy<Relativity.Services.Interfaces.Script.IScriptManager>())
    using (HttpClient client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("X-CSRF-Header", "-");
        client.DefaultRequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("<user login>:<user password>")));
        client.DefaultRequestHeaders.Add("X-Kepler-Version", "2.0");
        client.BaseAddress = new Uri("http://<host name>/");
 
        string inputJSON = @"{""ScriptRequest"":{""ScriptBody"":""<script><name>My script Name</name><description>About my script</description><category></category><input> <constant id=\""count\"" name=\""Rows\"" type=\""number\"" /></input><display type =\""itemlist\""/><action returns =\""table\""><![CDATA[ SELECT TOP(CAST(#count# AS INT)) * FROM [eddsdbo].[Artifact] ]]></action></script>"",""RelativityApplications"": []}}";
        string url = "/Relativity.rest/api/relativity.scripts/workspace/-1/scripts";
        HttpResponseMessage response = await client.PostAsync(url, new StringContent(inputJSON, Encoding.UTF8, "application/json"));
        response.EnsureSuccessStatusCode();
        string content = await response.Content.ReadAsStringAsync();
        scriptID = Int32.Parse(content);
    }
 
    return scriptID;
}

Add a script

Read script

Update script

Delete script

Import script

Get script parameters

Preview script

Enqueue run job

Read run job

Query action job results

Export action results

Export script report

Clean up run job