public string CreateIssue(Issue issue) { if (!_connection.IsAuthenticated) { throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In); } try { var fieldList = issue.ToExpandoObject(); var response = _connection.Post("issue", fieldList, HttpContentTypes.ApplicationJson); var customFields = fieldList.Where(field => !PresetFields.Contains(field.Key.ToLower())).ToDictionary(field => field.Key, field => field.Value); foreach (var customField in customFields) { ApplyCommand(response.id, string.Format("{0} {1}", customField.Key, customField.Value), "Applying custom field"); } return(response.id); } catch (HttpException httpException) { throw new InvalidRequestException(httpException.StatusDescription, httpException); } }
public virtual string CreateIssue(Issue issue, string projectId, string permittedGroup = null, bool disableNotifications = false) { if (string.IsNullOrEmpty(projectId)) { throw new ArgumentNullException("projectId"); } if (!Connection.IsAuthenticated) { throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In); } try { dynamic dynamicIssue = issue; if (string.IsNullOrEmpty(dynamicIssue.Summary as string)) { throw new ArgumentException("Issue must have a summary.", "issue"); } var requestParams = new Dictionary <string, string> { { "project", projectId }, { "summary", dynamicIssue.Summary } }; if (!string.IsNullOrEmpty(dynamicIssue.Description as string)) { requestParams["Description"] = dynamicIssue.Description; } if (!string.IsNullOrEmpty(permittedGroup)) { requestParams["permittedGroup"] = permittedGroup; } var apiResponse = Connection.Put <Issue>("issue", putParameters: requestParams); var createdIssueId = Regex.Match(apiResponse.Headers["Location"], @"issue/(?<issueId>[^/]+)$").Groups["issueId"].Value; var customFields = issue.ToExpandoObject().Where(field => !PredefinedIssueFields.Contains(field.Key.ToLower())).ToDictionary(field => field.Key, field => field.Value); foreach (var customField in customFields) { if (customField.Value == null) { continue; } ApplyCommand(createdIssueId, string.Format("{0} {1}", customField.Key, customField.Value), disableNotifications: disableNotifications); } return(createdIssueId); } catch (HttpException httpException) { throw new InvalidRequestException(httpException.StatusDescription, httpException); } }
public string CreateIssue(Issue issue) { if (!_connection.IsAuthenticated) { throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In); } try { var response = _connection.Post("issue", issue.ToExpandoObject(), HttpContentTypes.ApplicationJson); return(response.id); } catch (HttpException httpException) { throw new InvalidRequestException(httpException.StatusDescription, httpException); } }
public string CreateIssue(Issue issue) { if (!_connection.IsAuthenticated) { throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In); } try { var fieldList = issue.ToExpandoObject(); var response = _connection.Post("issue", fieldList, HttpContentTypes.ApplicationJson); var customFields = fieldList.Where(field => !PresetFields.Contains(field.Key.ToLower())).ToDictionary(field => field.Key, field => field.Value); foreach (var customField in customFields) { ApplyCommand(response.id, string.Format("{0} {1}", customField.Key, customField.Value), "Applying custom field"); } return response.id; } catch (HttpException httpException) { throw new InvalidRequestException(httpException.StatusDescription, httpException); } }
public string CreateIssue(Issue issue) { if (!_connection.IsAuthenticated) { throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In); } try { var response = _connection.Post("issue", issue.ToExpandoObject(), HttpContentTypes.ApplicationJson); return response.id; } catch (HttpException httpException) { throw new InvalidRequestException(httpException.StatusDescription, httpException); } }