User
This page contains the following information:
Note: The new authentication has moved a few fields from the user object to the new authentication model. This API will still update most of these fields but developers are encouraged to switch to the new protocol. The following fields that are backwards compatible are: Invalid Login Attempts, Changes Password, Maximum Password Age, Password Last Reset on, and Change password next login. The AuthenticationData field is supported only if the field is set to empty string or null. For more information on setting a user's authentication options, see Login Profile Manager (.NET).
GET method
You can use the GET method to retrieve a single User or a collection of Users. For more information, see Retrieve resources.
Retrieve a single User
When you retrieve a single User, you must supply a unique identifier (such as a GUID or ArtifactID) for the resource.
Sample URL
The URL contains the identifier for a User resource. You don't need to provide a body with a GET request.
/localhost/Relativity.REST/Relativity/User/1015314
Code sample
// 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 a User.
string url = "Relativity.REST/Relativity/User/1015314";
HttpResponseMessage response = httpClient.GetAsync(url).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.OK == response.StatusCode;
// Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);
Response
Retrieve a collections of Users
You can retrieve a collection of Users with the GET method.
Sample URL
The URL indicates that you are retrieving a collection of User resources. You don't need to provide a body with a GET request.
/localhost/Relativity.REST/Relativity/User
Code sample
//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 the User collection.
string url = "Relativity.REST/Relativity/User";
HttpResponseMessage response = httpClient.GetAsync(url).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.OK == response.StatusCode;
//Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);
Response
POST method
You can use the POST method to perform complex queries or to create resources. For more information, see Perform queries and Create resources.
Query for a User resource
You can set conditions used to query for a User resource.
Sample URL
/localhost/Relativity.REST/ Relativity /User/QueryResult
Code sample
//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 query on a User.
string url = "Relativity.REST/Relativity/User/QueryResult";
StringContent content = new StringContent(QueryInputJSON);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = httpClient.PostAsync(url, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.Created == response.StatusCode;
//Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);
Request
Response
Create a User resource
You can create a User with the POST method. For more information, see Create resources.
Sample URL
/localhost/Relativity.REST/Relativity/User
Code sample
//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 POST method on a User.
string url = "Relativity.REST/Relativity/User";
StringContent content = new StringContent(CreateInputJSON, Encoding.UTF8, "application/json");
HttpResponseMessage response = httpClient.PostAsync(url, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.Created == response.StatusCode;
// Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);
Request
Response
PUT method
You can use the PUT method to update properties on a User. For more information, see Create and update resources.
Sample URL
/localhost/Relativity.REST/Relativity/User/1015314
Code sample
//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 PUT method on a User
string url = "Relativity.REST/Relativity/User/1015314";
StringContent content = new StringContent(UpdateInputJSON, Encoding.UTF8, "application/json");
HttpResponseMessage response = httpClient.PutAsync(url, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.OK == response.StatusCode;
//Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);
Request
Response
DELETE method
You can use the Delete method to remove a User from the database. You don't need to provide a body with a DELETE request.
Sample URL
/localhost/Relativity.REST/Relativity/User/1015962
Code sample
// 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 DELETE method on a User.
string url = "Relativity.REST/Relativity/User/1015962";
HttpResponseMessage response = httpClient.DeleteAsync(url).Result;
string result = response.Content.ReadAsStringAsync().Result;
bool success = HttpStatusCode.OK == response.StatusCode;
// Parse the result with Json.NET.
JObject resultObject = JObject.Parse(result);