Im new on SharePoint 2016 and i want "POST" items to list `
var data = JSON.stringify($scope.formData);
console.log(data)
data = data.replace(/[{}]/g, '');
var datavalue = "{__metadata:{'type':'SP.Data.Task_x0020_ScheduleListItem'}," + data + "}";
$http({
url:"_api/web/lists/GetByTitle('Task%20Schedule')/items",
//url is working fine , I just took out complete url and placed end point here
method: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest":digestValue,
"X-HTTP-Method": "POST"
},
data: datavalue
}).then(function(response) {
digestValue=" ";
alert("success");
}, function(response) {
alert("failed");
});
could anyone please check what is wrong with this ? i have added digest value also but when I make post call i get this error
error: {code: "-1, Microsoft.SharePoint.Client.InvalidClientQueryException", message: {lang: "en-US",…}}
code: "-1, Microsoft.SharePoint.Client.InvalidClientQueryException"
message: {lang: "en-US",…}
lang: "en-US"
value: "A 'PrimitiveValue' node with non-null value was found when trying to read the value of a navigation property; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected."
data that i am passing :
{__metadata:{'type':'SP.Data.Task_x0020_ScheduleListItem'},"Task_x0020_Type":"Reporting","Country":"America","Title":"a","Schedule_x0020_Type":"Monthly","Monthly_x0020_Type":"Day","Assignee":"results":["Title":"Lye, Nicholas"],"Escalation_x0020_Point":"results":["Title":"Lye, Nicholas"],"Due_x0020_Hour":"? undefined:undefined ?","Due_x0020_Min":"? undefined:undefined ?","Relevant_x0020_Documents":"ff###@http;://vv$$$","Monthly_x0020_Value":"30"}