Skip to Content
0
Former Member
Mar 16, 2015 at 10:11 AM

Error while using gateway batch calls in odata service version 3

86 Views

Hi,

When i try using odata service version 2 http://services.odata.org/V2/(S(jvnw2atkierlyqqxvq0nzmoi))/OData/OData.svc/Products i am able to post to the backend, But when i use odata version 3 http://services.odata.org/V3/(S(uxbfifual2000tcet0xdj421))/OData/OData.svc/Products i am getting the following error.

below is my code

onInit: function() {
              
              this.oModel = sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V3/(S(q2cyyz1scxg3bh53xywlsagm))/OData/OData.svc/");
              //odata service version 3
              this.oModel.oHeaders = {
                           "DataServiceVersion" : "3.0",                   // first check the oModel data version, since we are using data version 3 in the 
                                                                                                              // in the service URL that we are accessing, we set out oModel version from 2 to 3
                           "MaxDataServiceVersion":  "3.0"                               // if not we get an error
                                  };
              sap.ui.getCore().setModel(this.oModel);


       },
       
       
       
       batch : function()
       {
                 
            var  contactEntry1 = { 
                      //type: "ODataDemo.Product",
                      ID: 11,
                    Name: "Breadbutterjam",
                    Description: "Whole",
                    ReleaseDate: "1994-01-01T00:00:00",
                    DiscontinuedDate: null,
                    Rating: 5,
                    Price: 3.5
               
             };
             
             var contactEntry2 = { 
                       //type: "ODataDemo.Product",
                       ID: 12,
                    Name: "sdsdfsdf",
                    Description: "sdf grain bread",
                    ReleaseDate: "1992-01-01T00:00:00",
                    DiscontinuedDate: null,
                    Rating: 4,
                    Price: 4.5
                       
                     
              
             };  
             var batchChanges = [];  
             batchChanges.push( this.oModel.createBatchOperation("Products", "POST", contactEntry1) );  
             batchChanges.push( this.oModel.createBatchOperation("Products", "POST", contactEntry2) );  
             this.oModel.addBatchChangeOperations(batchChanges);  
              console.log(batchChanges);
              
                this.oModel.submitBatch(function(data) { 
                        
                       console.log(data);
                       
                       
                }, function(err) {  
                    alert("Error occurred ");  
                  });  
              
              
              
              
              
              
       }




Kindly help me with this.

Thanks & Regards,

Lahari

Attachments

odataerr.png (89.1 kB)