javascript有效修补程序文档错误
尝试在VSTS I中创建工作项成功。但是,当我还想为字段System.AreaPath赋值时,我失败了 我的代码(工作和不工作System.AreaPath): 代码包括javascript有效修补程序文档错误,javascript,azure-devops,Javascript,Azure Devops,尝试在VSTS I中创建工作项成功。但是,当我还想为字段System.AreaPath赋值时,我失败了 我的代码(工作和不工作System.AreaPath): 代码包括{\“op\”:“add\”,“path\”:“/fields/System.AreaPath\”,“value\”:\“+area+”} 给出错误: {“$id”:“1”,“innerException”:null,“message”:“您必须传递一个有效的 文档正文中的修补程序文档 请求“,”类型名称“:”Microsoft
{\“op\”:“add\”,“path\”:“/fields/System.AreaPath\”,“value\”:\“+area+”}
给出错误:
{“$id”:“1”,“innerException”:null,“message”:“您必须传递一个有效的
文档正文中的修补程序文档
请求“,”类型名称“:”Microsoft.VisualStudio.Services.Common.VSSPPropertyValidationException,
Microsoft.VisualStudio.Services.Common,版本=14.0.0.0,
文化=中立,
PublicKeyToken=hidden”,“typeKey”:“VssPropertyValidationException”,“errorCode”:0,“eventId”:3000}
我缺少什么?替换var area=“TestProject1\\area 51”代码>至var area=“TestProject1\\\\area 51”代码>
顺便说一下,您在代码中指定了多个区域键
var number = "1234";
var title = "Test Title";
var caller = "Test Caller";
var assignment_group = "Test Group";
var tags = "Bug";
var area = "TestProject1\\Area 51";
var assigned_to = "Test To";
var url = "https://[instance].visualstudio.com/DefaultCollection/TestProject1/_apis/wit/workitems/$Bug?api-version=2.2";
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(url);
request.setHttpMethod('PATCH');
var password = 'somePassword';
request.setBasicAuth(password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json-patch+json');
request.setRequestBody("[{\"op\":\"add\",\"path\":\"/fields/System.Tags\",\"value\":\""+tags+"\"},{\"op\":\"add\",\"path\":\"/fields/System.Title\",\"value\":\"[" + number + "] " + title + "\"},{\"op\":\"add\",\"path\":\"/fields/Microsoft.VSTS.TCM.SystemInfo\",\"value\":\"Assignment Group: "+assignment_group+"\nCaller: "+caller+"\nAssigned to: "+assigned_to+"\"}]");
var response = request.execute();
// {\"op\":\"add\",\"path\":\"/fields/System.AreaPath\",\"value\":\""+area+"\"}
var number = "1234";
var title = "Test Title";
var caller = "Test Caller";
var assignment_group = "Test Group";
var tags = "Bug";
var area = "TestProject1\\Area 51";
var assigned_to = "Test To";
var url = "https://[instance].visualstudio.com/DefaultCollection/TestProject1/_apis/wit/workitems/$Bug?api-version=2.2";
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(url);
request.setHttpMethod('PATCH');
var password = 'somePassword';
//,{\"op\":\"add\",\"path\":\"/fields/Microsoft.VSTS.Common.Priority\",\"value\":\"" + priority + "\"}
request.setBasicAuth(password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json-patch+json');
request.setRequestBody("[{\"op\":\"add\",\"path\":\"/fields/System.AreaPath\",\"value\":\""+area+"\"},{\"op\":\"add\",\"path\":\"/fields/System.AreaPath\",\"value\":\""+area+"\"},{\"op\":\"add\",\"path\":\"/fields/System.Tags\",\"value\":\""+tags+"\"},{\"op\":\"add\",\"path\":\"/fields/System.Title\",\"value\":\"[" + number + "] " + title + "\"},{\"op\":\"add\",\"path\":\"/fields/Microsoft.VSTS.TCM.SystemInfo\",\"value\":\"Assignment Group: "+assignment_group+"\nCaller: "+caller+"\nAssigned to: "+assigned_to+"\"}]");
var response = request.execute();
// {\"op\":\"add\",\"path\":\"/fields/System.AreaPath\",\"value\":\""+area+"\"}