Office 365 Create A New List In SharePoint 2013 Using REST API

Learn how to create lists in SharePoint 2013 using REST interface. This blog will help you learning the basics of REST API and how it works in SharePoint.
 
Steps
  1. Edit your SharePoint page and a Content Editor WebPart.
  2. Copy the below code and save it as txt format in your Site Assets library.
  3. Get the txt file link and give it in the CEWP.
  4. Click the createlist button.
That's it.
  1. <script type="text/javascript" src="https://gowthamr.sharepoint.com/sites/Test1/SiteAssets/jquery.min.js"></script>  
  2.           
  3.    
  4. <script type="text/javascript">  
  5.    
  6. $(document).ready(function(){  
  7. alert('test');  
  8.   
  9. $("#btnClick").click(function(){  
  10.   
  11. var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists";  
  12. alert(requestUri);  
  13. $.ajax({  
  14. url: requestUri,  
  15. type: "POST",  
  16. data:JSON.stringify({'__metadata': { 'type''SP.List' }, 'AllowContentTypes'true,'BaseTemplate': 100, 'ContentTypesEnabled'true'Description''My list description''Title''Office365' }),  
  17.  headers: {   
  18.             "accept""application/json;odata=verbose",  
  19.             "content-type""application/json;odata=verbose",  
  20.               
  21.             "X-RequestDigest": $("#__REQUESTDIGEST").val()  
  22.         },  
  23.          
  24. success: onSuccess,  
  25.          
  26. error: onError  
  27.      
  28. });  
  29.    
  30. function onSuccess(data) {  
  31.    
  32. alert(data+ ' List Created');  
  33. }  
  34.    
  35. function onError(error) {  
  36.     
  37. //  
  38. }  
  39.    
  40. });  
  41.   
  42. });  
  43.   
  44. </script>  
  45.   
  46. <input type="button" id="btnClick" value="Click to Create List"/>   
Was my blog is helpful to you? Please post your comment.