首页 文章

如何使用Microsoft Graph API创建SharePoint列表项?

提问于
浏览
0

我正在尝试使用Microsoft Graph API创建列表项到SharePoint endpoints . 我的网址如下:

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”

有人可以帮忙解决这个问题吗?

在这里,我尝试在列表中创建文档的元数据 .

1 回答

  • 1

    您无法上传文件(即在文档库中创建新的ListItem) . 您需要先使用OneDrive endpoints上传文件:

    PUT /v1.0/sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
    POST /v1.0/sites/{siteId}/drive/items/{driveItem-id}/createUploadSession
    

    将文件放入文档库后,可以使用SharePoint endpoints更新现有文件中的元数据:

    PATCH h/v1.0/sites/{site-id}/lists/{list-id}/items/{listItem-id}/fields
    
    {
        "FileLeafRef": "757391.pdf",
        "ContentType": "Document",
        "Application_x0020_Name": "ABC"
    }
    

相关问题