如何使用我们创建的模板添加新项目?有没有人知道?缺少 API 文档,没有添加模板的示例,也没有使用模板添加新项目的示例。请帮忙...!
问问题
432 次
2 回答
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
于 2015-09-14T20:12:08.520 回答
0
对于那些想查看 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;
}
于 2017-01-27T15:55:57.867 回答