i am using the below code snippet to update the column in the SharePoint document library on button click but not, same code is working for List but not Library. same time am not getting error also

any one try to execute this code in your system and let me know where am missing.

<script language="javascript" type="text/javascript">  



function updateMetadata(id) {
    var url = _spPageContextInfo.webAbsoluteUrl +"/_api/Web/Lists/getByTitle('MyDocuments')/Items(" + id + ")";


    var dfd = $.Deferred();



        'url': url,

        'method': 'POST',

        'data': JSON.stringify({

            '__metadata': {'type':'SP.MyDocumentsListItem'},

            'Title': 'Update Field Again'


        'headers': {

            'accept': 'application/json;odata=verbose',

            'content-type': 'application/json;odata=verbose',

            'X-RequestDigest': $('#__REQUESTDIGEST').val(),

            'X-Http-Method': 'MERGE',

            "If-Match": "*"


        'success': function (data) {
            var d = data;



        'error': function (err) {




    return dfd;

<input id="Button1" type="button" value="Update Metadata"/>
  • 1
    Please add some description to your question. Specify the problem, what part of code u have problem, what research you have done till now? – Asad Refai Apr 10 '17 at 6:17

Try using "Patch" instead of "Merge":

'X-Http-Method': 'PATCH'
  • Hi Alok, Thank you for your quick response. but it is not working for both PATCH and MERGE. same time its not giving any error also. i have placed an alert in Success method it is prompting as well. – rajendar Apr 10 '17 at 6:18
  • Hi Rajendar, pls check deferred implementation as per link sharepointempower.com/Lists/Posts/Post.aspx?ID=22 – Alok Kumar Gupta Apr 10 '17 at 7:37
 '__metadata': {'type':'SP.MyDocumentsListItem'},

if your library name is MyDocuments that should be

 '__metadata': {'type':'SP.MyDocumentsItem'},
  • No luck. this one also not resolved my issue. still not updating the item. – rajendar Apr 10 '17 at 9:13
  • Just to rule this out, if you open /_api/Web/Lists/getByTitle('MyDocuments')/Items in the browser you should get a bunch of xml code. The item type is in there like this <category term="SP.Data.Shared_x0020_DocumentsItem" ... In this example the name of the library is just documents, so it's not necessarily derived from the current library name – JJD Apr 11 '17 at 6:55

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.