The code attempts to deserialize the json response, giving a null reference exception

Ravesh Kumar
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!
March 17, 2020

Hi ,

I am fetching (story or sub-task) data from JIRA SDK with following nuget package 

<package id="Atlassian.SDK" version="12.1.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" />
<package id="RestSharp" version="106.10.1" targetFramework="net46" /> 

I used below function to fetch the result 

IPagedQueryResult<Issue> result = await jira.Issues.GetIssuesFromJqlAsync("project = 'CREDRE' AND issuetype='Story' and updatedDate>= -4d ORDER BY id DESC", int.MaxValue);

but some some story or task it return an error giving a null reference exception.JIraIssue_2.JPGJIRAIssue1.jpg

Please see attached screens of exact issue while fetching (story or sub-task) from JIRA API.

Stack Trace error :

at Atlassian.Jira.Remote.MultiObjectCustomFieldValueSerializer.<FromJson>b__2_0(JToken j)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Atlassian.Jira.Remote.MultiObjectCustomFieldValueSerializer.FromJson(JToken json)
at Atlassian.Jira.Remote.RemoteIssueJsonConverter.<GetCustomFieldValuesFromObject>b__9_1(JProperty field)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Atlassian.Jira.Remote.RemoteIssueJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Atlassian.Jira.Remote.IssueService.<>c_DisplayClass20_0.<GetIssuesFromJqlAsync>b_2(JObject issueJson)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()

4 answers

1 vote
Tamás Gönczi
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!
August 28, 2024

You can bypass this problem if you enable UserPrivacyMode on the JiraClient level


// To be able to handle User Picker (multiple users) field type properly
jiraClient.RestClient.Settings.EnableUserPrivacyMode = true;

Aliaksandr Shustouski
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!
August 28, 2024

Thanks. This works

1 vote
Chetan Lohade February 20, 2024

Facing same issue. Any resolution?

0 votes
Aliaksandr Shustouski
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!
August 28, 2024

Atlassian.SDK 13 the same problem.

Always null reference exception after reading result after GetIssuesFromJqlAsync

0 votes
calh
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!
June 7, 2024

Needs a simple null check in MultiObjectCustomFieldValueSerializer. For personal use, I decompiled and added a single '?' to make it work. The project seems abandoned though since 2022... 

Suggest an answer

Log in or Sign up to answer