public async Task <JiraCreateIssueResponse> CreateIssueAsync(JiraAction action, Error error, string accountName) { var url = GetUrl(action); var userName = GetUsername(action); var password = GetPassword(action); var projectKey = GetProjectKey(action); var client = new JsonRestClient(url) { Username = userName, Password = password }; var fields = new Dictionary <string, object> { ["project"] = new { key = projectKey }, ["issuetype"] = new { name = action.Name }, ["summary"] = error.Message.CleanCRLF().TruncateWithEllipsis(255), ["description"] = RenderDescription(error, accountName) }; var components = action.GetComponentsForApplication(error.ApplicationName); if (components?.Count > 0) { fields.Add("components", components); } var labels = action.Labels.IsNullOrEmpty() ? null : action.Labels.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (labels?.Length > 0) { fields.Add("labels", labels); } var payload = new { fields }; var result = await client.PostAsync <JiraCreateIssueResponse, object>("issue", payload).ConfigureAwait(false); var commentBody = RenderVariableTable("Server Variables", error.ServerVariables) + RenderVariableTable("QueryString", error.QueryString) + RenderVariableTable("Form", error.Form) + RenderVariableTable("Cookies", error.Cookies) + RenderVariableTable("RequestHeaders", error.RequestHeaders); if (commentBody.HasValue()) { await CommentAsync(action, result, commentBody).ConfigureAwait(false); } result.Host = GetHost(action); return(result); }
public async Task <string> Comment(JiraAction actions, JiraCreateIssueResponse createResponse, string comment) { var url = GetUrl(actions); var userName = GetUsername(actions); var password = GetPassword(actions); var client = new JsonRestClient(url); client.Username = userName; client.Password = password; var payload = new { body = comment }; var resource = String.Format("issue/{0}/comment", createResponse.Key); var response = await client.PostAsync <string, object>(resource, payload).ConfigureAwait(false); return(response); }
public async Task <string> CommentAsync(JiraAction actions, JiraCreateIssueResponse createResponse, string comment) { var url = GetUrl(actions); var userName = GetUsername(actions); var password = GetPassword(actions); var client = new JsonRestClient(url) { Username = userName, Password = password }; var payload = new { body = comment }; var resource = $"issue/{createResponse.Key}/comment"; var response = await client.PostAsync <string, object>(resource, payload); return(response); }