我正在尝试在 Sharepoint 列表中的多人或组字段(仅限人员)中添加多个用户,但我收到以下错误消息
“从 JSON 读取器读取时发现意外的‘PrimitiveValue’节点。预期是‘StartObject’节点。”
我已使用 REST 调用在 Sharepoint 列表中添加项目,当我在其余调用中删除多人列时,项目会正确添加。
$scope.formData = { Title: $scope.codeNumber, SBMTestId:{ "results": [17,15] } }
var data = JSON.stringify($scope.formData);
var listName = "Test";
data = data.replace(/[{}]/g, '');
var datavalue = "{__metadata:{'type':'SP.Data.TestListItem'}," + data + "}";
$http({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items",
method: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
data: datavalue
}).then(function (response) {
alert("Go on!");
}, function (response) {
alert("Something is wrong. Please try after sometimes");
});
错误信息如下:
data:
error:
code:"-1, Microsoft.SharePoint.Client.InvalidClientQueryException"
message:
lang:"en-US"
value:"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."