Skip to main content
added tags
Link
John-M
  • 5.9k
  • 3
  • 19
  • 36
added 104 characters in body
Source Link
Taran Goel
  • 4.5k
  • 5
  • 21
  • 44

Code:

  function createListItem() { 
            var item =  {
                "__metadata": { "type": "SP.Data.listnameListItem" },   
                "Title": "testsetsetset",
                "Column1": "Test", 
                "Column2": "Test" , 
            } ;

        $.ajax({
              url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
            },
            error: function (data) {
                alert("Failure");
            }
        }); 

}

}

I can insert the title to the list,

  but after I added the column1 and column2 field in the request. There is a error:

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Code:

function createListItem() { 
        var item =  {
            "__metadata": { "type": "SP.Data.listnameListItem" },   
            "Title": "testsetsetset",
            "Column1": "Test", 
            "Column2": "Test" , 
        } ;

    $.ajax({
          url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
        },
        error: function (data) {
            alert("Failure");
        }
    });

}

I can insert the title to the list,

  but after I added the column1 and column2 field in the request. There is a error:

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Code:

  function createListItem() { 
            var item =  {
                "__metadata": { "type": "SP.Data.listnameListItem" },   
                "Title": "testsetsetset",
                "Column1": "Test", 
                "Column2": "Test" , 
            } ;

        $.ajax({
              url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
            },
            error: function (data) {
                alert("Failure");
            }
        }); 

}

I can insert the title to the list, but after I added the column1 and column2 field in the request. There is a error:

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Code:

function createListItem() { var item = { "__metadata": { "type": "SP.Data.listnameListItem" },
"Title": "testsetsetset", "Column1": "Test", "Column2": "Test" , } ;Code:

function createListItem() { 
        var item =  {
            "__metadata": { "type": "SP.Data.listnameListItem" },   
            "Title": "testsetsetset",
            "Column1": "Test", 
            "Column2": "Test" , 
        } ;

    $.ajax({
          url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
        },
        error: function (data) {
            alert("Failure");
        }
    });

}

I can insert the title to the list,

but after I added the column1 and column2 field in the request. There is a error: {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Code:

function createListItem() { var item = { "__metadata": { "type": "SP.Data.listnameListItem" },
"Title": "testsetsetset", "Column1": "Test", "Column2": "Test" , } ;

    $.ajax({
          url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
        },
        error: function (data) {
            alert("Failure");
        }
    });

}

I can insert the title to the list,

but after I added the column1 and column2 field in the request. There is a error: {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Code:

function createListItem() { 
        var item =  {
            "__metadata": { "type": "SP.Data.listnameListItem" },   
            "Title": "testsetsetset",
            "Column1": "Test", 
            "Column2": "Test" , 
        } ;

    $.ajax({
          url: apphostweb + "/_api/web/lists/getbytitle('" + listname + "')/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("Successful");            
        },
        error: function (data) {
            alert("Failure");
        }
    });

}

I can insert the title to the list,

but after I added the column1 and column2 field in the request. There is a error:

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.listnameListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}

Can we create whole item using this method? OR another method should be used?

Source Link
Loading