I have read lots of articles on C# Corner, as well as on other online websites about CRUD operations on Sharepoint List. In most articles, I have found some redundant code which can be reused and utilized in such a way that any new developer or learner can learn from the code.
So, based on that, I have started working on creating SPRest Utility which will do lots of work internally to increase development speed with much less coding. As I am still working and it is not fully optimized, there is still redundant code and methods which I have to delete.
You might be wondering how to use SPRest for CRUD Operation in SharePoint.
First of all, save the above code in a file and then, add the reference to it on the page wherever you want to use it.
If you want to use this SPRest utility in your SPFx web part or add it using TypeScript, then you can find compatible SpRest.ts at my repo.
Once you have added references, then create the instance of SPRest with one parameter which accepts Sharepoint rootUrl used internally or generating request URL for REST API.
var spRest=new SPRest("https://brgrp.sharepoint.com")
For demonstration purposes, I am using "PlaceHolderList" that is having the following columns.
Title -Single line of Text
UserId - Number
Completed -Single line of Text
Get All List Items from Sharepoint List
By default, SharePoint List returns the top 100 records if you have more than 100 records in the list.