【问题标题】:Download SharePoint List Attachment with REST API使用 REST API 下载 SharePoint 列表附件
【发布时间】:2022-08-20 08:49:10
【问题描述】:

使用 SharePoint REST API,我可以毫无问题地从文档库下载文件。但现在我想从列表中下载附件。

我可以找到我的列表,并且可以使用 SP 或 Graph API 列出我的附件,这没有问题。例如:https://docs.microsoft.com/en-us/graph/api/listitem-list?view=graph-rest-1.0&tabs=http 或 /_api/web/lists/getbytitle(\'ListName\')/items(1)/AttachmentFiles 给我一个很好的附件 URL 列表,但不是文件本身。

如果我在 URL 上尝试使用授权的 GET,我会得到 401。但如果我只是将 URL 粘贴到它下载的浏览器中。

我已经看到它可能与 SP Powershell 一起使用,但我无法在此解决方案中使用它。

我找不到下载它的 API。这可能吗?

如果我可以将它作为 Base64 字符串获得,则可以加分。

    标签: api sharepoint sharepoint-list


    【解决方案1】:

    您必须循环访问附件并附加 /$value 以检索数据。 您可以在 Microsoft 文档中找到更多详细信息:https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest#working-with-files-attached-to-list-items-by-using-rest

    GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles('{file_name}')/$value
    Authorization: "Bearer " + accessToken
    Accept: "application/json;odata=verbose"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      • 1970-01-01
      • 2019-07-16
      • 2015-11-30
      • 2019-06-06
      相关资源
      最近更新 更多