Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to update list item using Rest

$
0
0

Hello Guys,

How to update list items ? this is my code:

<script type="text/javascript">
function UpdateMetaData(){
    var listName="Restpost";
    var listItemId= 1;
    var item = {"__metadata": { "type": 'SP.Data.postListItem'},"Title": "value change"  
    };
    $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items("+listItemId+")",
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(item),
        headers: {"Accept": "application/json;odata=verbose","X-RequestDigest": $("#__REQUESTDIGEST").val(),"X-HTTP-Method": "MERGE","If-Match": "*"
        },
        success: function (data) {
            alert('Success');
            console.log(data);
        },
        error: function (data) {
            alert("Error");
        }
    });
}</script>

Thanks for your help


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>