Office 365 Add New List Item In SharePoint 2013 Using REST API

Learn how to create list item in SharePoint 2013 using REST interface. This blog will help you to learn REST API basics and how that 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. <script type="text/javascript">  
  4.    
  5. $(document).ready(function(){  
  6.   
  7.   
  8. $("#btnClick").click(function(){  
  9.   
  10. var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('newlist')/items";  
  11. alert(requestUri);  
  12. $.ajax({  
  13. url: requestUri,  
  14. type: "GET",  
  15.  headers: {   
  16.             "accept""application/json;odata=verbose"  
  17.              
  18.         },  
  19.          
  20. success: onSuccess,  
  21.          
  22. error: onError  
  23.      
  24. });  
  25.    
  26. function onSuccess(data) {  
  27. $.each(data.d.results,function(index,val){  
  28.   
  29.        alert(val.Title);  
  30.   
  31. });  
  32.   
  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 Item"/>  
Thanks for reading my blog.