Reputation: 31
How can i add new project using our template created ? is there any one knows? lack of API Documentation with no examples of adding templates and no examples of Adding New Project Using Template. Please Help...!
Upvotes: 0
Views: 522
Reputation: 99
For those that would like to see the c# code. Here is how I got this to work.
[HttpGet]
public void CreateProject()
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("name", "my test project 1");
dictionary.Add("templateID", "1234567890"); //pre-existing template id
dictionary.Add("sessionID", _sessionID);
try
{
var postResponse = Post_HttpResponseMessage("project", dictionary);
}
catch (Exception ex)
{
throw;
}
}
private HttpResponseMessage Post_HttpResponseMessage(string taskToPerform, IEnumerable<KeyValuePair<string, string>> postData)
{
HttpResponseMessage responseMessage;
using (var apiManagementSystem = new HttpClient())
{
apiManagementSystem.BaseAddress = new Uri("https://mycompany.preview.workfront.com/attask/api/");
apiManagementSystem.DefaultRequestHeaders.Clear();
var jsonMediaType = new MediaTypeWithQualityHeaderValue("application/json");
apiManagementSystem.DefaultRequestHeaders.Accept.Add(jsonMediaType);
apiManagementSystem.DefaultRequestHeaders.Add("SessionID", _sessionID);
HttpContent httpContent = new FormUrlEncodedContent(postData);
responseMessage = apiManagementSystem.PostAsync(taskToPerform, httpContent).Result;
}
return responseMessage;
}
Upvotes: 0
Reputation: 33381
You should create project as usual just defining templateID
field in addition.
POST /attask/api/v5.0/project HTTP/1.1
Host: <yourdomain>.attask-ondemand.com
Content-Type: application/x-www-form-urlencoded
name=your project name&templateID=55f7...5ed2&sessionID=f9de...12c5
Upvotes: 2