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

not able to update list item using rest api

$
0
0

Hi,

I am trying to update list item using respt api (using below referebce)

1) ajaydholeblogs.blogspot.com/2017/05/update-sharepoint-list-item-using-rest.html.

and also I have tried this link as well

2) http://sharepointcoding.com/2017/10/03/updating-list-item-sharepoint-20162013-using-rest-api/

not able to update using link  2 as well

as I try to update it gives below error

How can I resolve this error...

Thanks

Code:

method called updateItem(164,newtile)

 function updateItem(itemId, title) {
        $.ajax(
        {
            url: _spPageContextInfo.webServerRelativeUrl +
            "/_api/web/lists/getByTitle('userlst')/getItemByStringId('" +
            itemId + "')",
            type: "POST",
            contentType: "application/json;odata=verbose",
            data: JSON.stringify(
            {
                '__metadata': {
                    'type': 'SP.Data.
userlstListItem'
                },
                'Title': title,
                'Flag': 3
            }),
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "IF-MATCH": "*",
                "X-Http-Method": "PATCH"
            },
            success: function (data) {
                alert('Item updated successfully in
userlst List.');
            },
            error: function (e) {
                alert(e.message);
            }
        }
        );
    }




Viewing all articles
Browse latest Browse all 7589

Trending Articles



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