I have created the list called "dept info" in SharePoint 2013. And I have tried the API call to insert the item into list.but the list name contains the spance.if without space the other list items are inserted .with space is not working. the API code is,
SupportInfoListName="Dept%20Info";
var itemType = GetItemTypeForListName("Dept%20Info");
var item = {
"__metadata": { "type": itemType },
"Title": "56464*/**"
};
$.ajax({
url:"siteirl/_api/web/lists/getByTitle('Dept Info')/items","
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(item),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert("success");
},
error: function (data) {
alert(data);
}
});
// Get List Item Type metadata
function GetItemTypeForListName(name) {
console.log(name);
return "SP.Data." + name.charAt(0).toUpperCase() + name.split(" ").join("").slice(1) + "ListItem";
}
Suggest an idea to insert an item using API into list.