コード例 #1
0
        //creates an issue with the included information and returns the issue key for adding comments
        public static string CreateIssue(string description, string summary, IList <string> labels, string assignee)
        {
            //creates a sendissue object with the provided information to be converted to JSON
            SendIssue issue = new SendIssue
            {
                Description = description,
                Summary     = summary,
                Labels      = labels,
                Assignee    = assignee
            };

            //converts issue to JSON
            string stringissue = ConvertJson(issue);

            //sends request to create issue and stores the response information
            string response = RunQuery("issue", null, null, stringissue, "POST");

            //parses response information
            JObject jsonissue = JObject.Parse(response);

            //gets and returns issue key to be used to add comments
            string key = jsonissue["key"].ToString();

            return(key);
        }
コード例 #2
0
        //converts a sendissue into JSON to be passed in the create issue request
        public static string ConvertJson(SendIssue issue)
        {
            JObject data = JObject.FromObject(new
            {
                fields = new
                {
                    project = new
                    {
                        key = issue.Project
                    },
                    summary     = issue.Summary,
                    description = issue.Description,
                    issuetype   = new
                    {
                        name = issue.Type
                    },
                    labels   = issue.Labels,
                    assignee = new
                    {
                        name = issue.Assignee
                    }
                }
            });

            string returnstring = JsonConvert.SerializeObject(data);

            return(returnstring);
        }