Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

OData - CURD operation issue

Hi,

This is my code. I want to do an update. However, I am facing this issue -"ReferenceError: OData is not defined".

function ajaxWrite(link, parameters){

  OData.request

  ({

  requestUri: link,

        method: "GET",

        headers:{     

           "X-Requested-With": "XMLHttpRequest",

           "Content-Type": "application/atom+xml",

           "DataServiceVersion": "2.0",        

           "X-CSRF-Token":"Fetch"

                }       

  },

  function (data, response){

      OData.request

      ({

          requestUri: link,

          method: "PUT", 

          headers: {

          "X-Requested-With": "XMLHttpRequest",                      

          "Content-Type": "application/atom+xml;type=entry; charset=utf-8",

          "DataServiceVersion": "2.0",

          "Accept": "application/atom+xml,application/atomsvc+xml,application/xml",

          "X-CSRF-Token": response.headers['x-csrf-token']==undefined? response.headers['X-CSRF-Token']: response.headers['x-csrf-token']

                   },

           data: parameters  

        },

        function (data){

                success();

                // refresh the timeline

                sap.ui.getCore().getModel("timelineModel").loadData(URL.Timeline.link, '', false);

                loadTimeline();

        },

        function (err){

        error(null, "Error in PUT operation");

        }

      );

  },

  function (err){

  error(null, "Error in GET operation");

  }

  );

}

Tags:
Former Member
Former Member replied

I do an update like this:

var oModel = new sap.ui.model.odata.ODataModel("..........URL OF SERVICE.....", true);

oModel.update("/Entity("+id+")", data, null, function(){}, function(){});

2 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question