A team is attempting to develop a custom widget on VSTS to facilitate group code reviews. One of the tasks is to create a new work item with the type "Code Review Response" and link it to code changes. However, the current code is not functioning as expected:
import WorkitemRestClient = require("TFS/WorkItemTracking/RestClient");
var workitemClient = WorkitemRestClient.getClient();
var c = VSS.getWebContext();
import VersionCtrlRestClient = require("TFS/VersionControl/TfvcRestClient");
var versionCtrlClient = VersionCtrlRestClient.getClient();
versionCtrlClient.getChangesets(c.project.name)
.then(changesets => {
for (var i = changesets.length - 1; i >= 0; i--) {
var content = $("#content");
content.append("<pre>" + JSON.stringify(changesets[i].comment, null, "\t") + "</pre>");
workitemClient.createWorkItem([{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "",
"title": "xxxx",
"url": changesets[i].url
}
}], c.project.name, "Code Review Response")
.then(workitem => {
//workitem.relations.push({
// "attributes": { "key": [] },
// "rel": "",
// "title": "",
// "url": changesets[i].url
//});
});
}
});
The issue is not clear. It consistently returns a 400 bad request error indicating that the referenceName cannot be null. Is there an error in our code? The first parameter of createWorkItem requires a
document: VSS_Common_Contracts.JsonPatchDocument
, but I am unsure how to correctly pass this parameter.
Could anyone offer assistance? Thank you.