gpt4 book ai didi

javascript - 如何修复在多人或组字段中添加用户时 SharePoint 中的错误(仅限人员)

转载 作者:行者123 更新时间:2023-12-01 01:01:39 24 4
gpt4 key购买 nike

我正在尝试在 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."

最佳答案

尝试以下 JSON 数据格式。

{
"__metadata": { "type": "SP.Data.MyList2ListItem" },
"Title": "RestApiCreated",
"MultiUsersId": { "results": ["12", "23"] }
}

关于javascript - 如何修复在多人或组字段中添加用户时 SharePoint 中的错误(仅限人员),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56010089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com