I am working on a piece of automation for the creation of Task issues.
C#, Visual Studio 2019, .Net Framework 4.7.2, Jira v8.9.0, Atlassian.SDK 12.1.1
One of the requirements from the team who manages our on-premise Jira solution is that every issue is linked to the parent issue.
Here's the custom field definition.
"customfield_12604":{
"required":false,
"schema":{
"type":"issue",
"custom":"com.codedpoetry.easylinks.easy-links:com.codedpoetry.easylinks.easy-links.configurable-single-issue-picker",
"customId":12604
},
"name":"Child of - Link",
"fieldId":"customfield_12604",
"hasDefaultValue":false,
"operations":["set","remove"]
}
Here's what my code look likes.
Issue issue = client.CreateIssue(projectKey);
issue.Summary = summary;
issue.Type = issueType;
issue.Assignee = assignedTo;
issue.Priority = priority;
issue["Initiative Link"] = initiativeLink;
issue.Components.Add(components);
issue.Labels.Add(label);
issue.FixVersions.Add(fixVersion);
issue["Target Date"] = dueDate.ToJsonFormat();
issue["Planview Project #"] = pvNumber;
issue.Description = summary + "\r\n\r\nCreated by S&E Jira Tasker";
issue["Child of - Link"] = "PM-803"; // <-- This fails
issue.SaveChanges();
Here is the exception I get back from the server:
- System.AggregateException: One or more errors occurred. --->
- System.InvalidOperationException: Response Status Code: 400. Response Content: {"errorMessages":[],"errors":{"customfield_12604":"data was not an object"}}
- at Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest request, IRestResponse response)
- at Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__11.MoveNext()
- --- End of stack trace from previous location where exception was thrown ---
- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
- at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
- at Atlassian.Jira.Remote.IssueService.<CreateIssueAsync>d__23.MoveNext()
- --- End of inner exception stack trace ---
- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
- at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
- at System.Threading.Tasks.Task`1.get_Result()
- at Atlassian.Jira.Issue.SaveChanges()
- at Frontier.BssTool.SandEjiraTasker.JiraTask.<CreateIssue>d__0.MoveNext() in C:\code\TFS\Euro\SandEjiraTasker\SandEjiraTasker\JiraTask.cs:line 38
- ---> (Inner Exception #0) System.InvalidOperationException: Response Status Code: 400. Response Content: {"errorMessages":[],"errors":{"customfield_12604":"data was not an object"}}
- at Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest request, IRestResponse response)
- at Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
- at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
- at Atlassian.Jira.Remote.IssueService.<CreateIssueAsync>d__23.MoveNext()<---
Clearly I'm doing something wrong but I can't find documentation on how to do it right. Any pointers would be greatly appreciated.