如何使用 REST Move/Rename TFS Source Control 2015 中的文件 API?

How to Move/Rename a file in TFS Source Control 2015, using the REST API?

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

我post想要的URL是https://<server>/tfs/<Collection>/<Project>/_apis/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 上 renaming/moving 文件吗?

我刚想到使用 TFS Web 界面重命名并查看浏览器发送的请求。

事实证明这是正确的格式:

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