I am trying to create one new list item in Sharepoint 2010 using REST.
Coding
var itemProperties = {
'Title': ;Raja;, //Single line String
'Expiry_x0020_Date': "02/02/2016", //Date
'Permission_x0020_Type': 'Add' //Choice Column
};
createListItemREST('http://xyz:5000/sites/n/', 'L2', itemProperties, function(task){
console.log('Task' + task.TaskName + ' has been created');}, function(error){ console.log(JSON.stringify(error)); });
function createListItemREST(webUrl,listName, itemProperties, success, failure) {
$.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
type: "POST",
processData: false,
contentType: "application/json;odata=verbose",
data: JSON.stringify(itemProperties),
headers: {
"Accept": "application/json;odata=verbose"
},
success: function (data) {
success(data.d);
},
error: function (data) {
failure(data.responseJSON.error);
}
});
}
i am getting following error.
400 Bad request
{"code":"","message":{"lang":"en-US","value":"Error processing request stream. The property name 'Expiry_x0020_Date' specified for type 'Microsoft.SharePoint.DataService.L2Item' is not valid."}}
Note: When trying with only Title column this coding is working.
Column Details
Title - Single Line Text
Business Justification for Access - Choice Column
Expiry Date - Date and Time
Permission Type - Choice Column
<ViewFields xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<FieldRef Name="Attachments" />
<FieldRef Name="LinkTitle" />
<FieldRef Name="Business_x0020_Justification_x00" />
<FieldRef Name="Expiry_x0020_Date" />
<FieldRef Name="Permission_x0020_Type" />
</ViewFields>