【问题标题】:Visual Studio Team Services - Attaching an attachment to a workitemVisual Studio Team Services - 将附件附加到工作项
【发布时间】:2016-06-20 05:05:08
【问题描述】:

我正在创建一个简单的桌面应用程序,它将工作项添加到 Visual Studio Team Services(以前的 Visual Studio Online)。我的概念应用程序即将完成,最后一个元素是将文件作为附件发送。 发送工作,它只是将附件附加到工作项。我不断收到 Method not allowed 响应。

代码很简单,因为我试图限制任何可能阻止它工作的东西。

谁能指出这张图片有什么问题?

【问题讨论】:

    标签: c# api azure-devops attachment patch


    【解决方案1】:

    添加附件需要“补丁”方法,试试下面的代码:

    using Microsoft.VisualStudio.Services.WebApi;
    
    
    HttpResponseMessage response = client.PatchAsync(url, content).Result;
    response.EnsureSuccessStatusCode();
    

    而且你还需要在“msg”中添加“[”和“]”:

    msg.Append("[");
    ...
    msg.Append("]");
    

    【讨论】:

    • 嗨,谢谢。我试图寻找 PatchAsync,但似乎找不到所需的扩展等,所以我可以使用 Microsoft.VisualStudio.Services.WebApi 参考。听起来可能很愚蠢,但是您从哪里获得扩展程序?
    • 您好,谢谢您,但现在我收到了错误的请求。我只有 client.PatchAsJsonAsync 而不是 client.PatchAsync 的选项。
    • @ChrisCooper 我可以得到 client.PatchAsync。你在使用链接中的 nuget 包吗?
    • 对不起,我创建了一个覆盖方法,就是这样。我删除了覆盖并卸载并重新安装了 nuget 包并且它可以工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 2016-09-23
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多