atlassian.net-sdk-v2.0 /Atlassian.Jira/Remote/JiraRestService.cs

Language C# Lines 35
MD5 Hash 42e1b31ee7f30eba4e8e288be077f589 Estimated Cost $656 (why?)
Repository https://bitbucket.org/yyo/atlassian.net-sdk-v2.0.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RestSharp;
using Newtonsoft.Json.Linq;

namespace Atlassian.Jira.Remote
{
    public class JiraRestService
    {
        public IEnumerable<string> GetIssuesFromJql(string url, string username, string password, string jql, int startAt, int maxResults)
        {
            var restClient = new RestClient(url);
            if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
            {
                restClient.Authenticator = new HttpBasicAuthenticator(username, password);
            }

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "rest/api/latest/search";
            request.RequestFormat = DataFormat.Json;
            request.AddBody(new { jql = jql, startAt = startAt, maxResults = maxResults });

            var response = restClient.Execute(request);

            var json = JObject.Parse(response.Content);

            return from i in (JArray)json["issues"]
                   select i.ToString();
        }
    }
}
Back to Top