Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Atlassian.Net SDK: Setting a Custom Field of type Issue fails with "Data was not an object"

Amber Clark
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 18, 2020

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:

  1. System.AggregateException: One or more errors occurred. --->
  2. System.InvalidOperationException: Response Status Code: 400. Response Content: {"errorMessages":[],"errors":{"customfield_12604":"data was not an object"}}
  3. at Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest request, IRestResponse response)
  4. at Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__11.MoveNext()
  5. --- End of stack trace from previous location where exception was thrown ---
  6. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  7. at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  8. at Atlassian.Jira.Remote.IssueService.<CreateIssueAsync>d__23.MoveNext()
  9. --- End of inner exception stack trace ---
  10. at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
  11. at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
  12. at System.Threading.Tasks.Task`1.get_Result()
  13. at Atlassian.Jira.Issue.SaveChanges()
  14. at Frontier.BssTool.SandEjiraTasker.JiraTask.<CreateIssue>d__0.MoveNext() in C:\code\TFS\Euro\SandEjiraTasker\SandEjiraTasker\JiraTask.cs:line 38
  15. ---> (Inner Exception #0) System.InvalidOperationException: Response Status Code: 400. Response Content: {"errorMessages":[],"errors":{"customfield_12604":"data was not an object"}}
  16. at Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest request, IRestResponse response)
  17. at Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__11.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
  18. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  19. at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  20. 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.

0 answers

Suggest an answer

Log in or Sign up to answer