【问题标题】:How can I download attachments from a list in SharePoint using an API?如何使用 API 从 SharePoint 中的列表下载附件?
【发布时间】:2021-10-01 12:09:43
【问题描述】:

如何使用 Python 中的 API 从 SharePoint 中的列表(而不是页面的文档)下载附件?

我有一个包含 60 多行的列表,其内容是从 Power App 表单添加的。每行是一个不同的条目,可能有也可能没有附件。

我正在开发一个自动化流程,该流程将读取列表的每一行并将其输入 SAP。 我似乎找不到可以从列表中获取附件的 API,它们都是关于从页面的文档文件夹中获取它们。

下面是我正在使用的网站 URL,以及列表的样子。

https://{site url}/sites/{group name}/Lists/{listname}/AllItems.aspx?e=3%3A32b71e288cd841f5b13422c0b99ffe89&at=9

【问题讨论】:

    标签: python rest sharepoint automation


    【解决方案1】:
    function GetListItemAttachments() {
    // Specify the Id of the Item that you want to fetch
    var Itemid = 1;
    
    $.ajax
    ({
        // _spPageContextInfo.webAbsoluteUrl - will give absolute URL of the site where you are running the code.
        // You can replace this with other site URL where you want to apply the function
    
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('List Name')/items(" + Itemid + ")/AttachmentFiles",
        method: "GET",
        headers:
           {
               // Accept header: Specifies the format for response data from the server.
               "Accept": "application/json;odata=verbose"
           },
        success: function (data, status, xhr) {
            var dataresults = data.d.results;
            for (var i = 0; i < dataresults.length; i++) {
                alert(dataresults[i]["FileName"]);
            }
        },
        error: function (xhr, status, error) {
            console.log("Failed");
        }
    });
    }
    

    阅读更多:Get All Attachments From List Item in SharePoint using REST API

    【讨论】:

    • 感谢@Allen_MSFT,不过我正在寻找python API。
    猜你喜欢
    • 2022-08-20
    • 2016-02-22
    • 2021-11-04
    • 1970-01-01
    • 2014-11-08
    • 2015-01-25
    • 2022-11-11
    • 2015-09-21
    • 2020-01-15
    相关资源
    最近更新 更多