Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 9169

Update and Create operation problem with sapui5

$
0
0

Hi,

 

I have created sample bank application one month ago which is having Create, Update and Delete operation in eclipse . Then it's working fine.

 

But now when I run the same application  I am getting error in Create and Update operation.

 

I didn't made changes in the application and in the service.

 

I am getting below error in console for both create and Update operations like below.

 

 

TypeError {stack: (...), message: "undefined is not a function"}

 

  1. message: "undefined is not a function"
  2. stack: (...)
  3. get stack: function () { [native code] }
  4. set stack: function () { [native code] }
  5. __proto__: Error

 

I don't know why I am getting this error.

I never faced this error before.

 

 

For sample, below is my code for Update operation.

 

OData.request({  

 

           requestUri: "http://gwserver:8000/sap/opu/odata/sap/Z_TM_BANK_SRV/BankCollection/?$filter=bankCountry eq'AR'",  

           method: "GET",  

            headers: {

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

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

                      "DataServiceVersion": "2.0",          

                      "X-CSRF-Token":"Fetch"      

                           }                    

                  },  

 

                  function (data, response) 

                  {

                   console.log(response);

                   header_xcsrf_token = response.headers['x-csrf-token']; 

                   OData.request 

                   ({  

                      requestUri: "http://gwserver:8000/sap/opu/odata/sap/Z_TM_BANK_SRV/BankCollection(bankCountry='"+ selectedCount + "',bankID='"+ selectedId+ "')",  

                       method: "PUT",  

                        headers: {  

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

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

                            "DataServiceVersion": "2.0",  

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

                             "X-CSRF-Token": header_xcsrf_token  

                                                 },  

                              data:  

                                  {

                              bankCountry: bankCountry_var,  

                              bankID:bankID_var, 

                              bankName:bankName_var, 

                              region: region_var, 

                              street: street_var, 

                              city: city_var

                              }  

                           },

                            

                           function (data, response) 

                             {

                                 alert("put");

                                 console.log(response);

                        

                           var oSubDialog = new sap.ui.commons.Dialog( {title: "Updated",

                           content : [new sap.ui.commons.Label({

                           text : "Data Updated Successfully"

                           })]});

                           oSubDialog.open();

                           oSubDialog.addButton(new sap.ui.commons.Button({text: "OK", press:function(){oSubDialog.close();}}));

 

                                          $("<div>Returned data " + window.JSON.stringify(data) + "</div>").appendTo($("#MessageDiv")); 

                                        //      document.location.reload(true);

                             },  

                                    function (err)  

                                    { 

                              alert("error in put operation");

                              console.log(err);    //error function

                                         $("<div>Returned error " + window.JSON.stringify(err.response) + "</div>").appendTo($("#MessageDiv")); 

                                    } 

                         ); 

                 },  

                        function (err)  

                        { 

                             var request = err.request; // the request that was sent. 

                             var response = err.response; // the response that was received. 

                             alert("Error in Get -- Request "+request+" Response "+response); 

                        } );

 

In this code GET operation is working fine and I am getting response and CSRF token. When I am sending data to the PUT request with the CSRF token I am getting the above error.

 

Before it's working fine but now it's not working without making any changes in service and application code.

 

Please help me resolve this issue.

 

 

Thanks&Regards

Sridevi


Viewing all articles
Browse latest Browse all 9169

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>