JIRA rest api来获取活动流

时间:2014-12-19 03:48:12

标签: jira jira-plugin jira-rest-api jira-rest-java-api jira-mobile-connect

我正在尝试使用下面的api获取我的jira实例的活动流并且它无法正常工作,是否有人能指出我正确的方向?

2 个答案:

答案 0 :(得分:1)

您应该查看此页面:https://developer.atlassian.com/docs/atlassian-platform-common-components/activity-streams/consuming-an-activity-streams-feed

只有在您的Feed阅读器中登录时,活动流的Atom Feed才能正常运行。

答案 1 :(得分:1)

这里是使用基本身份验证通过Jira API使用活动流的示例。这在C#中,但是基本模式可以在任何地方应用:

string myJiraUsername = "username";
string myJiraPassword = "password"; //or API token
string authenticationHeaderValue = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(myJiraUsername + ":" + myJiraPassword));

System.Net.Http.HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authenticationHeaderValue);
Task<HttpResponseMessage> task = client.GetAsync("https://mycompany.atlassian.net/activity");
task.Wait();
HttpResponseMessage response = task.Result;

string resultOfApiCall = "";
if (response.IsSuccessStatusCode)
{
    resultOfApiCall = response.Content.ReadAsStringAsync().Result;
    Console.WriteLine("This was returned by your API request:\n" + resultOfApiCall);
}