post https://restapi.tpondemand.com/api/v1/Undelete
Undelete a user or a project
Resources which can be restored via API:
- Users (use /Users to get a list of deleted users)
- Projects (use /DeleteProjects to get a list of deleted projects)
Any other resource cannot be restored via API
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace REST.Test
{
class Program
{
static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// undelete Project ID#229
string query = "undelete";
HttpContent payload = new StringContent("{Id:229,EntityType:'Project'}", Encoding.UTF8, "application/json");
//using access token generated at Personal Details page (Access Tokens tab)
query += "?access_token=MTpoUmx4WW1LTzF6dlkvbUN1dTZIclVBUFQyQ1Z0MkN6YnF6OHBETmRZN2kwPQ==";
Console.WriteLine("Posting to " + query);
HttpResponseMessage response = client.PostAsync(query, payload).Result;
if (response.IsSuccessStatusCode)
{
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
}
}
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace REST.Test
{
class Program
{
static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// undelete Project ID#229
string query = "undelete";
HttpContent payload = new StringContent("{Id:229,EntityType:'Project'}", Encoding.UTF8, "application/json");
//using access token generated at Personal Details page (Access Tokens tab)
query += "?access_token=MTpoUmx4WW1LTzF6dlkvbUN1dTZIclVBUFQyQ1Z0MkN6YnF6OHBETmRZN2kwPQ==";
Console.WriteLine("Posting to " + query);
HttpResponseMessage response = client.PostAsync(query, payload).Result;
if (response.IsSuccessStatusCode)
{
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
}
}
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace REST.Test
{
class Program
{
static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// undelete Project ID#229
string query = "undelete";
HttpContent payload = new StringContent("{Id:229,EntityType:'Project'}", Encoding.UTF8, "application/json");
//using basic authentication (here 'John' is login and '123' is password)
string authentication = Convert.ToBase64String(Encoding.ASCII.GetBytes("admin:admin"));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authentication);
Console.WriteLine("Posting to " + query);
HttpResponseMessage response = client.PostAsync(query, payload).Result;
if (response.IsSuccessStatusCode)
{
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
}
}
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace REST.Test
{
class Program
{
static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// undelete Project ID#229
string query = "undelete";
HttpContent payload = new StringContent("{Id:229,EntityType:'Project'}", Encoding.UTF8, "application/json");
//using no authentication will result in 401 Unauthorized response
Console.WriteLine("Posting to " + query);
HttpResponseMessage response = client.PostAsync(query, payload).Result;
if (response.IsSuccessStatusCode)
{
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
}
}
}
Restoring several entities at once
Starting with Targeprocess 3.10.9 you can restore several entities at once by using /api/v1/undelete/bulk endpoint.