4
votes

My situation

I am using the Microsoft Graph API (Beta) to update SharePoint ListItems. However, I am failing to change the value of a 'Person or Group' column. The column has the attribute 'Allow multiple selections' and accepts both persons and groups. This is how it looks like as part of the ListItem columnSet:

{ 
  "AssignedTo": [
    {
      "Email": "[email protected]", 
      "LookupId": 123, 
      "LookupValue": "User Name"
    }
  ]
}

What works

Updating the value of columns other than 'Person or Group' is working fine: As documented, I am sending a PATCH request to the ListItem's columnSet. The request header contains the content type 'application/json' and the request body contains a JSON-encoded dictionary of column names and their (new) values:

{
  "RegularColumn": "new value"
}

What does NOT work

I have experimented quite a bit with using the user's id, email and/or name, but all I get is this error: 'The request is malformed or incorrect.'

How can I update the value of a 'Person or Group' column? How would a sample JSON request body look like?

Thanks for any suggestions!

3
Can you use Fiddler and share with us the request and response URLs and body?Michael Mainer
Did you find solution or workaround? Also the same issue with Taxonomy fields.Ruslan Korkin
@RuslanKrak I eventually gave up and as a result updating these types of columns is still not supported by our application. It's not a priority anymore either.Jakob Keller
@MichaelMainer Apologies for the lack of Response to your requests. I'm not a regular user here, at least not being logged in.Jakob Keller
@JakobKeller Thanks for replyRuslan Korkin

3 Answers

2
votes

I have been looking for a solution to the same issue for quite a while and did not find any solutions on StackOverflow or the web. Thanks to the post from Vadim Gremyachev (See the related question regarding fields of type 'lookup' here), I was able to successfully update a field of type 'personOrGroup' with the activated setting 'allowMultipleSelection' via the Graph Api. You can update single value 'personOrGroup' fields, by combining the field name with LookupId and passing the LookupId as the value:

{
   "AssignedToLookupId":"123"
}

If you want to update a multi value 'personOrGroup' fields, you need to specify the data type first and pass the ids as an array:

{
   "[email protected]":"Collection(Edm.String)",
   "AssignedToLookupId":["123", "124"] 
}
0
votes

I think I found a workaround how to make it instead of Graph: use the sharepoint rest api for creating/updating multiple 'Person or Group' field instead of Graph api using AAD Client (ADAL.js) with connection to Application in your AAD. It works both for SPFx webpart and Azure Functions. But anyway, pity that officially there is no info from microsoft.

0
votes

After lot of tinkering around I managed to find solution to this through use of msgraph, without having to switch back to sharepoint v1.0 api. Solution:you can pull the user's list using displayName: "User Information List"

example: GET https://graph.microsoft.com/v1.0/groups/{group-id}/sites/root/lists/User Information List/ (This contains the lookup ids for users. Also, in other words, this is the list being used by personOrGroup column for lookups)

In case of a new entry, similarly, you will first need to add to above list a new listItem in usual way and then use that new created id to set LookupField as suggested above in answer.