Interface IHttpService
Represents the HTTP service that provides a set of methods to communicate with Relativity REST API.
Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IHttpServiceExamples
_httpService = relativityFacade.Resolve<IHttpService>();Properties
| Improve this Doc View SourceBaseUrl
Gets the base URL address.
Declaration
string BaseUrl { get; }Property Value
| Type | Description | 
|---|---|
| System.String | 
Username
Gets the username.
Declaration
string Username { get; }Property Value
| Type | Description | 
|---|---|
| System.String | 
Methods
| Improve this Doc View SourceDelete(String, Object, UserCredentials)
Executes a DELETE HTTP request without response to the specified relativeUri
with optionally content serialized to JSON.
Declaration
void Delete(string relativeUri, object content = null, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Examples
int agentId = 1234;
var dto = new
{
	force = true
};
_restService.Delete($"relativity.agents/workspace/-1/agents/{agentId}", dto);Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Delete<TResult>(String, Object, UserCredentials)
Executes a DELETE HTTP request to the specified relativeUri
with optionally content serialized to JSON,
then deserializes the response content to TResult and returns it.
Declaration
TResult Delete<TResult>(string relativeUri, object content = null, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Returns
| Type | Description | 
|---|---|
| TResult | The response content deserialized to  | 
Type Parameters
| Name | Description | 
|---|---|
| TResult | The type of the result to deserialize response content to. | 
Examples
int workspaceId = 12345;
int applicationFieldCodeId = 345;
string url = $"relativity-imaging/v1/workspaces/{workspaceId}/application-field-codes/{applicationFieldCodeId}";
_restService.Delete<bool>(url);Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Get<TResult>(String, UserCredentials)
Executes a GET HTTP request to the specified relativeUri,
then deserializes the response content to TResult and returns it.
Declaration
TResult Get<TResult>(string relativeUri, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Returns
| Type | Description | 
|---|---|
| TResult | The response content deserialized to  | 
Type Parameters
| Name | Description | 
|---|---|
| TResult | The type of the result to deserialize response content to. | 
Examples
JObject result = _restService.Get<JObject>($"relativity.agents/workspace/-1/agents/{id}");Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Post(String, Object, UserCredentials)
Executes a POST HTTP request without response to the specified relativeUri
with optionally content serialized to JSON.
Declaration
void Post(string relativeUri, object content = null, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Examples
var dto = new
{
	workspaceArtifactID = 54321,
	searchArtifactID = 12345
};
_restService.Post("Relativity.Services.Search.ISearchModule/Keyword%20Search%20Manager/DeleteSingleAsync", dto);Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Post<TResult>(String, Object, Double, UserCredentials)
Executes a POST HTTP request to the specified relativeUri
with optionally content serialized to JSON,
then deserializes the response content to TResult and returns it.
Declaration
TResult Post<TResult>(string relativeUri, object content = null, double timeout = 2, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| System.Double | timeout | Number of minutes to wait before timeing out. Default is 2. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Returns
| Type | Description | 
|---|---|
| TResult | The response content deserialized to  | 
Type Parameters
| Name | Description | 
|---|---|
| TResult | The type of the result to deserialize response content to. | 
Examples
var dto = new
{
	Request = new
	{
		Object = new
		{
			ArtifactID = 12345
		}
	}
};
_restService.Post<string>($"Relativity.Objects/workspace/{workspaceId}/object/delete", dto);var dto = new
{
	batchSet = new
	{
		Name = "Test Batch Set",
		BatchPrefix = "TEST1",
		BatchSize = 10,
	}
};
BatchSet result =  _restService.Post<BatchSet>($"Relativity.Services.Review.Batching.IBatchingModule/workspaces/{workspaceId}/batching/CreateBatchSet", dto, new UserCredentials { Username = "FakeAccount", Password = "FakePassword" });Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Put(String, Object, UserCredentials)
Executes a PUT HTTP request without response to the specified relativeUri
with optionally content serialized to JSON.
Declaration
void Put(string relativeUri, object content = null, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Examples
int artifactId = 123453;
var dto = new
{
	groupRequest = new
	{
		Client = new
		{
			Secured = false,
			Value = new
			{
				12345
			}
		},
	}
};
_restService.Put($"relativity.groups/workspace/-1/groups/artifactId", dto);Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. | 
Put<TResult>(String, Object, UserCredentials)
Executes a PUT HTTP request to the specified relativeUri
with optionally content serialized to JSON,
then deserializes the response content to TResult and returns it.
Declaration
TResult Put<TResult>(string relativeUri, object content = null, UserCredentials userCredentials = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | relativeUri | The endpoint relative URI. | 
| System.Object | content | The content object. | 
| UserCredentials | userCredentials | User credentials to be used when perfroming action over Relativity Api. | 
Returns
| Type | Description | 
|---|---|
| TResult | The response content deserialized to  | 
Type Parameters
| Name | Description | 
|---|---|
| TResult | The type of the result to deserialize response content to. | 
Examples
LibraryApplicationInstallStatusResponse response;
using (var form = new MultipartFormDataContent())
using (var memory = new StreamContent(new MemoryStream(bytes)))
{
	var optionsString = JsonConvert.SerializeObject(dto, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
	using (var optionsContent = new StringContent(optionsString, Encoding.UTF8, "application/json"))
	{
		form.Add(optionsContent, "request");
		form.Add(memory, "rapStream");
		response = _restService.Put<LibraryApplicationInstallStatusResponse>("Relativity.LibraryApplications/workspace/-1/libraryapplications", form);
	}
}Exceptions
| Type | Condition | 
|---|---|
| System.Net.Http.HttpRequestException | The response has System.Net.Http.HttpResponseMessage.IsSuccessStatusCode equal to false. |