使用智能表API C#下载行附件

时间:2017-08-01 08:47:55

标签: c# smartsheet-api

我在下面提到链接

link

并使用以下行 -

     public void downloadAttachment(Attachment attach)
    { 
        SmartsheetRequest getAttachment = new SmartsheetRequest { callURL = "/attachment/" + attach.Id, method = "GET", contentType = "application/json" };
        var jsonGetAttachment = getAttachment.MakeRequest("null");
        getAttachment.DownloadAttachment(jsonGetAttachment["url"], jsonGetAttachment["sizeInKb"], jsonGetAttachment["name"]);
    }

下载附件。

但是以下一行

        Stream responseStream = request.GetResponse().GetResponseStream(); 
“MakeRequest”方法中的

给出“远程服务器返回错误:(404)Not Found。”错误。

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法。

解决方案: -

以下代码行 -

SmartsheetRequest getAttachment = new SmartsheetRequest { callURL = "/attachment/" + attach.Id, method = "GET", contentType = "application/json" };

更改为以下行 -

SmartsheetRequest getAttachment = new SmartsheetRequest { callURL = "/sheets/" + SheetID + "/attachments/" + attach.Id, method = "GET", contentType = "application/json"};