我想从板和打印问题的摘要(使用JIRA:https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getIssuesForBoard)获得问题,但我不想得到所有问题的字段,我需要字段:"sprint“和"epic”。
我有错误:
未处理的异常: System.NullReferenceException:对象引用未设置为对象的实例。
在线上:
var response = client.RestClient.ExecuteRequest<ResponseIssues>(Method.GET,
@"/rest/agile/1.0/board/2/issue?fields='epic,sprint'");代码(C#):
var client = Atlassian.Jira.Jira.CreateRestClient(jiraurl, login, password);
var response = client.RestClient.ExecuteRequest<ResponseIssues>(Method.GET,
@"/rest/agile/1.0/board/2/issue?fields='epic,sprint'");
foreach (var issue in response.issues)
{
Console.WriteLine(issue.fields.epic.summary);
}类ResponseIssues (C#):
public class ResponseIssues
{
public string expand;
public int startAt;
public int maxResults;
public int total;
public List<Issue_> issues;
}
public class Issue_
{
public string expand;
public string id;
public string self;
public string key;
public Field fields;
}
public class Field
{
public Sprint sprint;
public Epic epic;
}
public class Sprint
{
public int id;
public string self;
public string state;
public string name;
}
public class Epic
{
public int id;
public string self;
public string name;
public string summary;
public Color color;
public bool done;
}
public class Color
{
public string key;
}发布于 2016-10-27 02:38:42
好像有些东西没有被正确初始化。每当这种情况发生在我身上时,我就用赋值来打破链,试图找出哪个对象是空的。还捕获异常,并在visual studio中探索它。在您的情况下,尝试如下:
try{
var client = Atlassian.Jira.Jira.CreateRestClient(jiraurl, login, password);
// Add breakpoint... is client null? There could be an issue with your login, password or the url you've passed.
// Or maybe it's Atlassian.Jira.CreateRestClient (instead of Jira.Jira.CreateRestClient), though that should get flagged by the compiler unless there's some recursion or parenting in the Jira namespace
var restClient = client.RestClient;
// Add breakpoint... is restClient null? Could be that CreateRestClient is lazy-loading, in which case I'd look at the url, login and password again.
var response = restClient.ExecuteRequest<ResponseIssues>(Method.GET,
@"/rest/agile/1.0/board/2/issue?fields='epic,sprint'");
}
catch(Exception ex)
{
Console.WriteLine(ex); // Or just breakpoint here and explore the exception.
}发布于 2016-10-26 18:53:31
简单的旅行“问题”“=>”字段“得到了你的”冲刺“和”史诗“。
发布于 2016-10-26 19:38:24
var response = client.RestClient.ExecuteRequest<ResponseIssues>(Method.GET,
@"/rest/agile/1.0/board/2/issue?fields='epic,sprint'");
var jo = JObject.Parse(response);
var id = jo["issues"]["fields"]['sprint']['id'].ToString();
var self= jo["issues"]["fields"]['sprint']['self'].ToString();
var state= jo["issues"]["fields"]['sprint']['state'].ToString();
var name= jo["issues"]["fields"]['sprint']['name'].ToString();
Console.WriteLine(id);
Console.WriteLine(self);
Console.WriteLine(state);
Console.WriteLine(name);
Console.Read();https://stackoverflow.com/questions/40269947
复制相似问题