Create SharePoint list item with lookup field with

2020-06-23 07:42发布

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

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?

2条回答
Luminary・发光体
2楼-- · 2020-06-23 08:10

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

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

查看更多
The star\"
3楼-- · 2020-06-23 08:23

You need to add a lookup column in the following format

"Office": "London",
"OfficeLookupId", "16"

Where Office is the name of the column

查看更多
登录 后发表回答