![](/img/trans.png)
[英]Unable to retrieve item count for Sharepoint List through Microsoft Graph API
[英]How to create SharePoint list item with Microsoft Graph API?
我正在尝试使用 Microsoft Graph API 创建到 SharePoint 端点的列表项。 我的网址如下:
https://graph.microsoft.com/v1.0/sites/{id}.sharepoint.com:/sites/{name of the site}:/lists/{list_id}/items
使用 POST 调用此 URL,以及如下所示的正文:
{
"fields": {
"FileLeafRef": "757391.pdf",
"ContentType": "Document",
"Application_x0020_Name": "ABC",
}
}
它给出的错误是
"message": "文件和文件夹只能通过 OneDrive API 添加到 DocumentLibrary"
有人可以对此提供帮助,如何解决此问题?
在这里,我正在尝试为文档创建元数据,并在列表中。
您不能像这样上传文件(即在文档库中创建新的ListItem)。 您需要先使用OneDrive 端点上传文件:
PUT /v1.0/sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
POST /v1.0/sites/{siteId}/drive/items/{driveItem-id}/createUploadSession
一旦您在文档库中拥有该文件,您就可以使用SharePoint 端点更新现有文件上的元数据:
PATCH h/v1.0/sites/{site-id}/lists/{list-id}/items/{listItem-id}/fields
{
"FileLeafRef": "757391.pdf",
"ContentType": "Document",
"Application_x0020_Name": "ABC"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.