var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('c2Dashboard Data')/items";

var digest = document.querySelector('#__REQUESTDIGEST').value;
var axiosConfig =  {
                  headers: {  
                        "Accept": "application/json;odata=verbose",                     
                        "X-RequestDigest": digest

var postData = { 
              Permanent: '0', 
              Itinerant: '0', 
              Region: 'Western', 
              Service: 'Army' 

axios.post(endPointUrl, postData, axiosConfig)
                        console.log('saved successfully')
               .catch(function(error) {

I get the following error about 'val' but there is no 'val' just 'value'

'Promise' is undefined File: axios.min.js, Line: 8, Column: 401

  • the problem isn't with your code, it's with your setup. – Derek Gusoff Jul 24 '18 at 12:01
  • What do you mean? – OLA Jul 24 '18 at 16:51
  • where does this code live? How's it deployed? How are you referencing your dependencies? – Derek Gusoff Jul 25 '18 at 12:26
  • The code is in SharePoint and used in a content editor webpart. The dependencies are referenced in an html file where my js file withe the axios code is referenced also. – OLA Jul 26 '18 at 14:04

Try using below code to POST your data in SharePoint list:

     async: true, 
     url: endPointUrl,  
     method: "POST",
     data: JSON.stringify({  
         '__metadata': {  
             'type': 'SP.Data.ListItem' // it defines the ListEntityTypeName  
         Permanent: '0', 
         Itinerant: '0', 
         Region: 'Western', 
         Service: 'Army' 
     headers: {  
         "accept": "application/json;odata=verbose",
         "content-type": "application/json;odata=verbose",
         "X-RequestDigest": $("#__REQUESTDIGEST").val()
     success: function(data) {  
         console.log("Item created successfully"); 
     error: function(error) {  


Before using this function pass the ListEntityTypeName of your own list in __metadata property.

You can get this property by hitting below url in browser tab:



  1. SP.List.entityTypeName property.

  2. CRUD Operations In SharePoint REST API Using jQuery AJAX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.