Attask Добавление нового проекта с использованием шаблона
Как я могу добавить новый проект, используя наш созданный шаблон? есть кто-нибудь знает? отсутствие документации по API без примеров добавления шаблонов и примеров добавления нового проекта с использованием шаблона. Пожалуйста помоги...!
2 ответа
Вы должны создать проект как обычно, просто определяя templateID
поле в дополнение.
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
Для тех, кто хотел бы увидеть код C#. Вот как я заставил это работать.
[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;
}