2017-03-20 34 views
0

§我一直在使用微軟網站上的TFS API。根據API文檔,here,我應該能夠通過發送PATCH請求隨着該類型的請求TFS API與Jquery

https://{instance}/DefaultCollection/{project}/_apis/wit/workitems/${workItemTypeName}?api-version={version} 

創建TFS工作項和我做data對象在AJAX請求這樣的:

[{ 
    "op": "add", 
    "path": { string } 
    "value": { string or int, depending on the field } 
}] 

但是,當我使用IIS Express服務器使用AJAX創建PATCH請求時,我得到404 Not Found Error

我不知道爲什麼會這樣。

+0

的路徑肯定是不正確...... – Ionut

+0

但我能夠做出GET請求非常相同的URL。你能提供一個向TFS服務器發送AJAX請求的例子嗎? –

回答

2

檢查我下面的例子中,我創建了一個名爲任務工作項cecetest1成功有以下要求:

var jsonObj = [{ 
         "op": "add", 
         "path": "/fields/System.Title", 
         "value": "cecetest1" 
       }]; 

        $.ajax({ 
         url: 'http://tfsserver:8080/tfs/TeamProjectCollection/TeamProject/_apis/wit/workitems/$Task?api-version=1.0', 
         type: 'PATCH', 
         contentType: "application/json-patch+json", 
         data: JSON.stringify(jsonObj), 
         cache: false, 
         dataType: 'json', 
         beforeSend: function (xhr) { 
          xhr.setRequestHeader("Authorization", "Basic " + btoa("domain\\username" + ":" + "password")); 
         }, 

         }) 
+0

這工作得很好! –