python - 如何使用 API 从 SharePoint 中的列表下载附件?
问题描述
如何使用 Python 中的 API 从 SharePoint 中的列表(而不是页面的文档)下载附件?
我有一个包含 60 多行的列表,内容是从 Power App 表单添加的。每行是一个不同的条目,可能有也可能没有附件。
我正在开发一个自动化流程,该流程将读取列表的每一行并将其输入 SAP。我似乎找不到可以从列表中获取附件的 API,它们都是关于从页面的文档文件夹中获取它们。
下面是我正在使用的站点 URL,以及列表的样子。
https://{site url}/sites/{group name}/Lists/{listname}/AllItems.aspx?e=3%3A32b71e288cd841f5b13422c0b99ffe89&at=9
解决方案
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");
}
});
}
推荐阅读
- python - 为什么我在 python 3.9 中不断收到属性错误
- php - 在 php(yii1.1 框架)中处理 csv 文件时,爱尔兰口音变为 wiered 字符
- python - 如何从单独的请求中结束无限循环?
- azure - 无法在 Azure VM 上更新 ubuntu
- python - 更改配置并加载在下游任务上微调的拥抱脸模型
- reactjs - 您如何在 useEffect 挂钩之外使用 Library Constructer?
- javascript - 返回一个不太小也不太大的数字用于操作?
- twitter-bootstrap - Bootstrap 5 beta SCSS 编译错误 Invalid CSS
- spring-boot - Spring sleuth 和 spring 集成为所有出站 API 请求生成相同的 traceId
- angular - 类型“false”不可分配给类型“EventEmitter”
'