Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Jira Rest Client API, Crashes after first few issues, C#

Luis Goncalves April 10, 2020

using Atlassian.SDK - ver. 12.1.0

Hey,

I'm trying to use Jira Api to get all the Issues of a certain type. I'm successfully able to connect to the endpoint and get my results using the method GetIssuesFromJqlAsync, but when I start to iterate through the list of issues it only goes as far as the first 8 issues after that I get the exception "System.NullReferenceException: 'Object reference not set to an instance of an object.'". I'm using a maximum of 100 items per request, but I never get that far.

This should be a simple call and it's really killing my time. Have we got any solution or workaround?

This is my method:
public static async Task<IPagedQueryResult<Issue>> GetIssues(int startAt)

{
var jira = Jira.CreateRestClient("url", "luser", "key", new JiraRestClientSettings());
string issuetype = "some type";
IssueSearchOptions options = new IssueSearchOptions($"type = \"{issuetype}\"");
options.MaxIssuesPerRequest = 100;
options.StartAt = startAt;

return await jira.Issues.GetIssuesFromJqlAsync(options);
}

This is how I'm calling it:
IPagedQueryResult<Issue> pagedQueryResult = Task.Run(() => GetIssues(0)).GetAwaiter().GetResult();

This is how I'm iterating:
foreach (Issue issue in pagedQueryResult)
{
// I do something
}

I really appreciate some help here.

1 answer

0 votes
Luis Goncalves April 10, 2020

Worked around debugging your Atlassian.SDK solution, Thank you for sharing, it was very useful.

Andy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2020

What was the solution in the end?  This is also killing me! :)
- Andy.

TomLint January 24, 2025

@Andyif you enable the EnableUserPrivacyMode setting on the Jira Client, you should be able to enumerate the Jira issues without any problems. Apparently, the API wrapper does not handle the case where, due to privacy settings, some properties are not returned by the REST API, causing the error.

Suggest an answer

Log in or Sign up to answer