0
I have installed the atlassian sdk and I am now following the documentation to try and query the tickets:
https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home
The docs show this:
// create a connection to JIRA using the Rest client
var jira = Jira.CreateRestClient("http://<your_jira_server>", "<user>", "<password>");
// use LINQ syntax to retrieve issues
var issues = from i in jira.Issues.Queryable
where i.Assignee == "admin" && i.Priority == "Major"
orderby i.Created
select i;
I have the code listed below this but I am entering the catch statement with the following error (it;s much bigger - this is just the first part of it!)
System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Atlassian.Jira.Remote.RemoteField[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path '', line 1, position 2. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal
So I think the way that I'm trying to retrieve the results through the foreach loop is incorrect?
foreach (var issue in issues)
{ results.InnerHtml += (issue.Key.Value + " -- " + issue.Summary);
}
But I'm really stuck as to how to retrieve them. Any help would be welcome! I'm a bit stumped!
Full code sample:
namespace JIRA_service_desk{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var jira = Jira.CreateRestClient("https://myurl.co.uk", "username", "pwd");
var issues = from i in jira.Issues.Queryable
where i.Assignee == "bob"
orderby i.Created
select i;
try
{
foreach (var issue in issues)
{ results.InnerHtml += (issue.Key.Value + " -- " + issue.Summary);
}
}
catch(Exception ex)
{ results.InnerHtml = ex.ToString();
}
//results.InnerHtml = issues.ToString();
}
}
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.