2

I am trying to save a list item in SP 2013 using REST API.

One of the fields, named AccessRights, is a People or Groups type field.

My code works fine when I use this:

dataToSave["AccessRightsId"] = 46;
//add other fields
//post through REST API

However, I need to save multiple groups or people in this field.

Following this blog post, I am trying to send the request like this:

enter image description here

Instead of just group ID, I am trying to use an object that consists of the "results" property that has an array of group IDs.

This fails with the following error:

Microsoft.SharePoint.Client.InvalidClientQueryException",

"message":{"lang":"en-US","value":"An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.

I've tried to use both string and number values in the array ("47" and 47), neither work.

What's the correct way to save multiple people or groups via REST API into a People or Group field?

3
  • 1
    From the error it looks like your field is not a multi-field. Can you verify that your user field is multivalued? Dec 1, 2016 at 10:19
  • @Kai you were right!
    – user56339
    Dec 1, 2016 at 10:20
  • 1
    Ok, I will add it as an answer :) Dec 1, 2016 at 10:22

2 Answers 2

1

The error says that PrimitiveValue expected.

That means SharePoint assumes your actual field type is single-value, you need to switch it to multiple selection.

0

Turns out this was because the "Allow multiple selections" option in the column settings was off. Need to change it to "Yes":

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.