I am trying to create a work item using the Microsoft.TeamFoundationService.Client api but everytime I try to create the work item it fails with the error
New work item updates must specify Area and Iteration node ids.
So far I have the following:
var connection = new VssConnection(baseUrl, vssBasicCredential);
var witClient = connection.GetClient<WorkItemTrackingHttpClient>();
var patchDocument = new JsonPatchDocument();
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.Title",
Value = title
});
...
var newlyCreatedUserStory = witClient.CreateWorkItemAsync(patchDocument,
testProject.Id,
"User Story").Result;
It is at this point the exception is thrown. I have tried to add in the values for Area and Interation node as well:
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaId",
Value = parentWorkItem.Fields["System.AreaId"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaPath",
Value = parentWorkItem.Fields["System.AreaPath"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.TeamProject",
Value = parentWorkItem.Fields["System.TeamProject"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.NodeName",
Value = parentWorkItem.Fields["System.NodeName"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaLevel1",
Value = parentWorkItem.Fields["System.AreaLevel1"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationId",
Value = parentWorkItem.Fields["System.IterationId"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationPath",
Value = parentWorkItem.Fields["System.IterationPath"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationLevel1",
Value = parentWorkItem.Fields["System.IterationLevel1"].ToString()
});
Any ideas? Thanks in advance.
Changing
Path = "/Fields/System.Title"
to
Path = "/fields/System.Title"
did the trick for me.
If you are going to use with TFS2015. Suggest you do not test with VSTS. There maybe some difference between both such as API version.
As far as I know create work item don't need to specify Area and Iteration node ids. Just need the title. Sample code you could refer official tutorial: Create a work item
Since you are using a preview library, you could also give a try with stable version such as Microsoft Team Foundation Server Client 14.102.0
Also add a similar question for your reference: TFS2015 REST API Library: Create a new Work Item
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With