我是使用TFS工作的新手。下面是我试图执行的代码检索项目的代码,我得到如下错误的代码。请建议我,如果我失去了一些东西。我正在使用TFS onpremise。VssPropertyValidationException:无法在TFS 2017中使用REST API获取工作项目
{ “的$ id”: “1”, “的InnerException”:空, “消息”: “你必须在请求主体传递查询对象。” “的typeName”:“微软.VisualStudio.Services.Common.VssPropertyValidationException,Microsoft.VisualStudio.Services.Common,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“, ”typeKey“:”VssPropertyValidationException“,”errorCode“:0,”eventId“ :3000}
var resturl = "tfs Server URL/tfs/collectionname/_apis/wit/wiql?api-version=1.0"
var query = "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Feature' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc";
$.ajax({
"url": resturl,
"type": "POST",
"Content-type": "application/json",
body: JSON.stringify(query),
headers: {
"Accept": "application/json"
},
success: function (data) {
alert('success');
},
error: function (error) {
alert('failure');
alert(error.statusText);
alert(error.responseJSON.message);
}
});
[编辑]:我能够从下面的代码的REST API检索的项目列表。
var resturl = "tfs Server URL/tfs/collectionname/_apis/projects?stateFilter=All"
$.ajax({
"url": resturl,
"type": "GET",
"Content-type": "application/json",
headers: {
"Accept": "application/json"
},
success: function (data) {
alert('success');
},
error: function (error) {
alert('failure');
alert(error.statusText);
alert(error.responseJSON.message);
}
});
发出定额。从[this]找到解决方案(https://social.msdn.microsoft.com/Forums/vstudio/en-US/20b2e061-ce0b-4d42-812c-b44065745d05/tfs-restful-api-wiql-workitem-query- lanaguage?forum = tfsgeneral)论坛。非常有用的一个。 – dia