使用 Microsoft Graph 创建带有查阅字段的 SharePoint 列表项字段、列表、Microsoft、Graph

2023-09-08 08:35:28 作者:你好有才i

我正在尝试使用 Microsoft Graph 的新 SharePoint 端点创建列表项.我的网址如下:https://graph.microsoft.com/beta/sites/{site-id}/列表/{list-id}/items

I am trying to create list items with Microsoft Graph's new SharePoint endpoint. My URL is as follows: https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items

使用 POST 调用此 URL,以及这样的正文:

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

{
    "fields": {
        "Title": "test",
    }
}

.. 有效!但是,如果我包含一个查找字段,则查找字段始终为空.我试过了

.. works! But if I include a lookup field, the lookup field is always empty. I have tried with

"{columnName}": "id",

"{columnName}": "id;#value",

"{columnName}": {
    "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", //and others like this
    "Id": "id",
    "Value": "value",
}

"{columnName}": "value",
"{columnName}Id": "id",

这些似乎都不起作用.有些会给出错误,例如请求格式错误或不正确.",有些会通过,但不包含查找字段.

None of these seems to work. Some give an error like "The request is malformed or incorrect.", others go through, but doesn't include the lookup field.

这方面的文档很少(如果有的话),而且我在谷歌上发现的信息很少(除了有人问同样的问题但没有答案).有人让这个工作了吗?有没有可能?

The documentation for this is scarce (if any), and I have found very little information on google (apart from someone asking the same question with no answers). Anyone that got this to work yet? Is it even possible?

推荐答案

我已经让它与禁用多项选择选项的人员字段一起使用.因此,如果您有一个仅允许一个人的人员字段,则以下内容有效.

I have got this to work with people fields where the multiple selection option was DISABLED. So if you have a person field which allows one person only, the following works.

"{columnName}LookupId": id

此外,id 仍然需要是 SP ID 而不是图形用户 GUID.此 ID 因站点而异.

Additionally, the id still needs to be the SP ID and not the graph user GUID. This ID changes from site to site.