喵-见缝插针 2017-03-20 14:35 采纳率: 0%
浏览 19

TFS API与Jquery

§I have been working with the TFS API that on the Microsoft website. According to the API documentation, here , I should be able to create a TFS workitem by sending a PATCH request with this type of request

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

and I make the data object in the AJAX request this:

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

However, when I create the PATCH request with AJAX using a IIS Express server, I get a 404 Not Found Error.

I have no idea why this would be the case.

  • 写回答

1条回答 默认 最新

  • weixin_33725270 2017-03-21 05:49
    关注

    Check my example below, I've created a task work item named cecetest1 successfully with the following request:

    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"));
                            },
    
                          })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用