如何使用Microsoft Graph API创建SharePoint列表项? [英] How to create SharePoint list item with Microsoft Graph API?

查看:86
本文介绍了如何使用Microsoft Graph API创建SharePoint列表项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to create list items with Microsoft Graph API to a SharePoint endpoint. My URL is as follows:

https://graph.microsoft.com/v1.0/sites/{id}.sharepoint.com:/sites/{name of the site}:/lists/{list_id}/items

使用POST调用此URL,并使用如下内容:

Calling this URL with POST, and a body like this:

{
    "fields": {
        "FileLeafRef": "757391.pdf",
        "ContentType": "Document",
        "Application_x0020_Name": "ABC",
    }
}

显示错误

消息":文件和文件夹仅应添加到 通过OneDrive API的DocumentLibrary"

"message": "Files and folders should only be added to a DocumentLibrary via the OneDrive API"

请问对此有何帮助,如何解决此问题?

Can some one help on this, how to fix this issue?

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

Here I am trying to create metadata for document, with in a list.

推荐答案

您不能像这样上传文件(即在文档库中创建 new ListItem).您需要首先使用

You cannot upload a file (i.e. create a new ListItem in a Document Library) like that. You will need to first upload the file using the OneDrive endpoints:

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

将文件保存在文档库中之后,就可以使用

Once you have the file in the document library, you can then update the metadata on the existing file using the 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"
}

这篇关于如何使用Microsoft Graph API创建SharePoint列表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆