【问题标题】:trouble using TFS Git Rest api to retrieve tree使用 TFS Git Rest api 检索树的问题
【发布时间】:2016-08-10 13:07:13
【问题描述】:

我在使用适用于 Git 的 TFS Rest API 检索树时遇到问题。

相关代码是

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", 'application/zip')
$DownloadTreeCmd = "http://tfs.mycompany.com:8080/tfs/myCollection/_apis/git/repositories/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/trees/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?api-version=1.0&filename=TempDownload.zip&recursive=1" 

$nresp = Invoke-RestMethod $DownloadTreeCmd -UseDefaultCredentials -Headers $headers

我最终在 $nrest 中发现了一些我无法阅读的内容。我尝试将其写入文件,但它不被识别为 zip 文件。我可以看到 I 中的数据似乎是二进制数据。

我应该如何处理这些数据。

【问题讨论】:

    标签: git rest tfs tfs-2015


    【解决方案1】:

    它可以工作,但我无法解释为什么它以前不工作。

    我得到了这个工作,但我不确定我是否理解这一点。 uri 上的文件名参数似乎没有做任何事情。返回的对象无法保存到 .zip 类型的文件中(实际上您可以保存它,但 zip 无法将其识别为存档)。

    为了完成这项工作,我只是从 uri 请求中删除了文件名,并将 -OutFile xxxx.zip 添加到 Invoke-RestMethod cmdlet。

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 1970-01-01
      • 2018-08-12
      • 2020-04-28
      • 2021-01-02
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      相关资源
      最近更新 更多