我正在尝试在Sharepoint列表中的多人或组字段(仅限人员)中添加多个用户,但出现以下错误消息
“从JSON读取器读取时发现意外的'PrimitiveValue‘节点。应为'StartObject’节点。”
我使用REST调用在Sharepoint列表中添加项目,当我删除rest调用中的多人列时,项目被正确添加。
$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."
发布于 2019-05-07 10:49:16
试试下面的JSON数据格式。
{
"__metadata": { "type": "SP.Data.MyList2ListItem" },
"Title": "RestApiCreated",
"MultiUsersId": { "results": ["12", "23"] }
}
https://stackoverflow.com/questions/56010089
复制相似问题