I am new to sharepoint.I am getting below error on ajax call i dont know where it is occuring. "{\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\" An entry without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified.\"}}}"

The below is the code which I used Please reply as soon.

var camlQueryRequest = { query: { __metadata: { type: "SP.CamlQuery" }, ViewXml: "" } }; var CamlViewXml = "A150434";

var query = new Query();
    var camlquerybuild;
    query.SPSiteUrl = _spPageContextInfo.webAbsoluteUrl;
    query.QueryType = "CAML";
    query.RequestMethod = "POST";
    query.RequestHeaders = {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "X-HTTP-Method": "POST",
        "content-length": 0,
        "content-type": "application/json;odata=verbose",
        "If-Match": "*"

    camlQueryRequest.query.ViewXml = CamlViewXml;
    camlquerybuild = camlQueryRequest;
    var camlquery = JSON.stringify(camlquerybuild);
    self.QueryData = camlquery;

   query.RequestHeaders["content-length"] = self.QueryData.length;
   self.SearchUrl = query.SPSiteUrl + "/_api/web/lists/" + "getbytitle('RFA')/Items?$select=ID,ESI_ProjectSeqNoLookupId";
           url: self.SearchUrl,
           method: query.RequestMethod,
           headers: query.RequestHeaders,
           data: self.QueryData,
           success: function (data) { deferredObject.resolve(data); },
           error: function (data) { deferredObject.reject(data); }

I think this occurs due to missing Type attribute in List Item entry.

If you want to create list items using REST you will need to include the list item type.

The list item type is a string automatically created by SharePoint when the list is first created.

You can generate this value using the list name.

The syntax is : SP.Data.{ListName}ListItem.

So if the list name is MyList, list item type will be SP.Data.MyListListItem.

your code should look like :

"__metadata": { "type": "SP.Data.MyListListItem" }

Something like this should work :

var YourModel = {
    "__metadata": { "type": "SP.Data.MyListListItem" }
var YourSearchUrl = 'your_search_url';
   url: YourSearchUrl,
   method: 'POST',
   headers: {
        "Accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
        "X-HTTP-Method": "POST",
        "content-type": "application/json;odata=verbose",
   data: JSON.stringify(YourModel),
   success: function (data) { 
    // Do something if success
   error: function (data) { 
    // Do something if error

In my SP 2013 webapp, I can create new list items using listdata.svc without having to specify the item type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.