Posts

Showing posts from August, 2021

SharePoint Get list items from List view- REST API

In the below code snippet, call the  getListViewItems method by passing the weburl, list title and the viewname. function   executeJson ( url ,  method ,  headers ,  payload ) {      method  =  method  ||  'GET' ;      headers  =  headers  || {};      headers [ "Accept" ] =  "application/json;odata=verbose" ;      if  ( method  ==  "POST" ) {          headers [ "X-RequestDigest" ] =  $ ( "#__REQUESTDIGEST" ). val ();     }      var   ajaxOptions  = {          url :   url ,          type :   method ,          contentType :   "application/json;odata=verbose" ,          headers :   headers     };      if  ( typeof   payload  !=  'undefined' ) {          ajaxOptions . data  =  JSON . stringify ( payload );     }      return   $ . ajax ( ajaxOptions ); } function   getListItemsByCAML ( webUrl ,  listTitle ,  queryText ) {      var   viewXml  =  '<View><Query>'  +  queryText  +  '</Query>

SharePoint Get list items by CAML query - REST API

 Below is the javascript code for getting list items by CAML Query. function   executeJson ( url ,  method ,  headers ,  payload ) {      method  =  method  ||  'GET' ;      headers  =  headers  || {};      headers [ "Accept" ] =  "application/json;odata=verbose" ;      if  ( method  ==  "POST" ) {          headers [ "X-RequestDigest" ] =  $ ( "#__REQUESTDIGEST" ). val ();     }      var   ajaxOptions  = {          url :   url ,          type :   method ,          contentType :   "application/json;odata=verbose" ,          headers :   headers     };      if  ( typeof   payload  !=  'undefined' ) {          ajaxOptions . data  =  JSON . stringify ( payload );     }      return   $ . ajax ( ajaxOptions ); } function   getListItemsByCAML ( webUrl ,  listTitle ,  queryText ) {      var   viewXml  =  '<View><Query>'  +  queryText  +  '</Query></View>' ;      var   url  =  webU