Visit Relativity Learning to explore additional learning opportunities for this topic.
Last date modified: July 09 2025
Relativity.API.Extensions
The Relativity.API.Extensions library provides additional helper functions that will be useful when interacting with RelativityOne environments in the cloud-based infrastructure. You can use the helper functions in this library to set up calls to REST services in a specific environment.
GetInstanceBaseURL - Allows you to build URLs to any API without assuming the host name. Use this method to safeguard your application against backend URL changes in the RelativityOne infrastructure.
BuildHTTPAuthorizationHeader - Allows populating the Authentication header on HTTP requests. Use this method to safeguard your application against backend authentication/authorization changes in RelativityOne.
While this is a new API focused more on interacting with RelativityOne through REST services, you can also continue to use the ServiceFactory, which provides the same benefits for consumers of RelativityOne .NET API client libraries.
The code sample below illustrates how to use the GetInstanceBaseURL and BuildHTTPAuthorizationHeader methods to construct a HTTP service call (you will need to reference Relativity.API.Extensions.dll in your project).
using Relativity.API.Extensions; publicclass AgentBaseTest : AgentBase { private IServicesMgr _servicesMgr;
publicAgentBaseTest() { }
publicoverridestring Name => "AgentBaseTest";
publicoverridevoidExecute() { _servicesMgr = Helper.GetServicesManager(); var client = HttpClientFactory.CreateClient(_servicesMgr, ExecutionIdentity.CurrentUser); var requestUrl = GetRequestUrl("/api/test-endpoint"); var request = newHttpRequestMessage(HttpMethod.Get, requestUrl); var response = client.SendAsync(request).Result; }
private Uri GetRequestUrl(string requestEndpoint) { var baseUrl = _servicesMgr.GetInstanceBaseURL(); if (string.IsNullOrEmpty(baseUrl)) { thrownewInvalidOperationException("Base URL is not set."); } var fullUri = newUri(newUri(baseUrl), requestEndpoint); return fullUri; } }
publicclass HttpClientFactory { privatestatic Lazy<HttpClientHandler> _sharedHandler => new Lazy<HttpClientHandler>();
The methods are applicable whenever you build your own http request using HttpClient. They also apply if you generate your own client library from our OpenAPI specification (OAS) files.
If your code uses our .NET SDKs and the ServiceFactory, your code is already insulated from change. If you are manually constructing http requests (and setting the service URL and authentication headers), your application may stop working in the future if you aren’t using these methods to build your requests.