无法在 Azure Devops 中设置 AreaPath 的新错误
Unable to set AreaPath of a new bug in Azure Devops
当我以编程方式创建一个新错误并将区域路径设置为此时:
VssBasicCredential credentials = new VssBasicCredential(string.Empty, personalAccessToken);
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project"
},
WorkItem bug = await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").ConfigureAwait(false);
我收到这个错误:
TF401346:为工作项 -1、字段 'System.AreaId' 提供的无效 Area/Iteration ID。
我认为这是一个错误,这个区域路径存在于 ADO 中。
问题不是区域路径而是另一个字段,无论出于何种原因 ADO 将区域路径指向问题。尝试逐一添加每个字段,或单独添加区域字段,看看是否能解决问题。这是我的代码的精简版。
JsonPatchDocument patchDocument = new JsonPatchDocument
{
//add fields and their values to your patch document
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title",
Value = $"{tag} for PR #{pullRequest.PullRequestId} changes in build {buildNumber} PlannerBuildArtifact."
},
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project\Planner\Service"
}
};
try
{
using VssConnection connection = new VssConnection(Uri, this._credentials);
using WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
return await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, Project, "Bug").ConfigureAwait(false);
}
catch (VssException e)
{
_log.LogError("Unable to create work item", e);
throw;
}
当我以编程方式创建一个新错误并将区域路径设置为此时:
VssBasicCredential credentials = new VssBasicCredential(string.Empty, personalAccessToken);
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project"
},
WorkItem bug = await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").ConfigureAwait(false);
我收到这个错误:
TF401346:为工作项 -1、字段 'System.AreaId' 提供的无效 Area/Iteration ID。
我认为这是一个错误,这个区域路径存在于 ADO 中。
问题不是区域路径而是另一个字段,无论出于何种原因 ADO 将区域路径指向问题。尝试逐一添加每个字段,或单独添加区域字段,看看是否能解决问题。这是我的代码的精简版。
JsonPatchDocument patchDocument = new JsonPatchDocument
{
//add fields and their values to your patch document
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title",
Value = $"{tag} for PR #{pullRequest.PullRequestId} changes in build {buildNumber} PlannerBuildArtifact."
},
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project\Planner\Service"
}
};
try
{
using VssConnection connection = new VssConnection(Uri, this._credentials);
using WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
return await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, Project, "Bug").ConfigureAwait(false);
}
catch (VssException e)
{
_log.LogError("Unable to create work item", e);
throw;
}