Some Important SharePoint REST API related to SharePoint list.


Some Important SharePoint REST API related to SharePoint list.


Get all lists of Current SP Site = https://{siteurl}/_api/web/lists      //CRUD list.
// siteurl may be like https://mycompany.sharepoint.com/sites/teamsite


REST API to get field by  field name = https://{siteurl}/_api/web/lists/getbytitle('Projects')/fields/getbytitle('Status')

GET SP list meta Data             = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')

GET Fields/column of SP list  = https://{siteurl}/_api/web/lists/getbytitle('" + listName + "')/fields

GET SP list fields with filter    = https://{siteurl} /_api/web/lists/getbytitle('SP List Name')/fields?$filter=Title%20eq%20%'Email'

Get GUID of List                     = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/Id

Get GUID of List EntityTypefullName  = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/ListItemEntityTypeFullName

GET SP list items(to perform CRUD list items) = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/items  //100 items at a time. 

GET SP list items(to perform CRUD list items) = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/items?$top=5000 //5000 items at a time.  It is maximum allowed content at time. Also you can use it for pagination

REST API to get value from lookup field = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/items?$select=*,Test_x0020_Volume/Title&$expand=Test_x0020_Volume

REST API to update/delete the list Items = https://{siteurl}/_api/web/lists/getbytitle('SP List Name')/items(85);

REST API to filter the list Items with two fields = https://{siteurl}/_api/lists/getbytitle('" + listName + "')/items?$filter=(AssignedTo eq '" + userId + "') and (Status ne 'Completed')

We can use any of above using REST api using below jquery ajax


$.ajax({
        url: _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists",
        headers: {
          Accept: "application/json;odata=verbose"
        },
        async: false,
        success: function (response,status,xhr) {
            console.log('Success- It will run if REST API is correct');
            console.log(response); // JSON Data
            console.log(status); // Status text success
            console.log(xhr); // an object with all jquery ajax methods and other thing
        },error: function (error,status) {
            console.log('Error -It will run if REST API is wrong');
            console.log(error);// 
            console.log(status);//an object with all jquery ajax methods,error message and other thing
           
        },complete: function (result,status) {
            console.log('Complete-It will run in every case eaither success or failure');
            console.log(result);//an object with all jquery ajax methods,error/success message and other thing.
            console.log(status);//Status text error
            
        }

});

// It will give you the current Page URL_spPageContextInfo.webAbsoluteUrl

Comments

Popular posts from this blog

Get list item entity type full name of a SharePoint list using REST API

Get SharePoint list name by GUID

Get Current Web Logged In User of SharePoint Site in jQuery