如何使用Visual Studio Team Foundation Server 2015上的rest api移动/重命名文件

2024-10-02 14:22:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Python和tfsrestapi在内部TFS上移动文件,服务器似乎只支持版本2之前的API,但是在MSDN上我找不到版本低于v4.1的任何文档

我要发布到的url是https:///tfs///u api/tfvc/changesets

目前,我对post请求的正确json正文的最佳猜测如下:

{
    "comment": "moved file",
    "changes": [{
        "changeType": "rename",
        "item": {
            "path": "<filepath>",
            "version": 468,
                    "sourceServerItem": "<filepath>"
        }

    }]
}

但是我不能得到更多的HTTp错误400坏的请求与以下消息

{
  "$id": "1",
  "innerException": null,
  "message": "Exactly one value for PathActions is required.\r\nParameter name: change.SourceServerItem",
  "typeName": "System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
  "typeKey": "ArgumentException",
  "errorCode": 0,
  "eventId": 0
}

就我的一生而言,我在google上找不到任何对PathActions的引用,这不是git而不是tfvc,也不是为这个项目提供值的正确方法。你知道吗

有人能通过HTTP请求重命名/移动TFVC上的文件吗?你知道吗


Tags: 文件文档https版本服务器apiurltfs
1条回答
网友
1楼 · 发布于 2024-10-02 14:22:18

我突然想到使用TFS web界面进行重命名,并查看浏览器发送的请求。你知道吗

原来这是正确的格式:

{
  "comment": "Moved File",
  "changes": [
    {
      "changeType": 8,
      "sourceServerItem": "<old path>",
      "item": {
        "path": "<new path>",
        "version": 470
      }
    }
  ]
}

相关问题 更多 >