cancel
Showing results for 
Search instead for 
Did you mean: 

Error while using gateway batch calls in odata service version 3

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos


this.oModel = sap.ui.model.odata.ODataModel("proxy//V3/(S(q2cyyz1scxg3bh53xywlsagm))/OData/OData.svc/", {

   maxDataServiceVersion : '3.0'
});

this.oModel.oHeaders = {

   "DataServiceVersion" : "3.0"
};

and

var contactEntry2 = {

   __metadata: { type: "ODataDemo.Product" },

   ID: 12,

   Name: "sdsdfsdf",

......

Former Member
0 Kudos

Hi Maksim,

        I tried including the metadata as mentioned. i am not getting any error,but when i check in the backend i couldn't see the data

This is the response.Please help.

Thanks & Regards,

Lahari

former_member182372
Active Contributor
0 Kudos

hm, worked for me

var contactEntry1 = {

   __metadata: { type: "ODataDemo.Product" },

   ID: 11,

   Name: "Breadbutter Jam",

   Description: "Whole",

   ReleaseDate: "1994-01-01T00:00:00",

   DiscontinuedDate: null,

   Rating: 5,

   Price: 3.5

};

var contactEntry2 = {

   __metadata: { type: "ODataDemo.Product" },

   ID: 12,

   Name: "Sandwich",

   Description: "Grain Bread",

   ReleaseDate: "1992-01-01T00:00:00",

   DiscontinuedDate: null,

   Rating: 4,

   Price: 4.5


Former Member
0 Kudos

Hi Maksim,

               Thanks,its working .

Thanks & Regards,

Lahari

Answers (1)

Answers (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

I guess, SAP NetWeaver Gateway does not support V3 of OData.

former_member182372
Active Contributor
0 Kudos

sapui5 sap.ui.model.odata.ODataModel claims 3.0 'experimental' support:

//OData version supported by the ODataModel: '2.0'. '3.0' may work but is currently experimental.),

funny that they removed the pharse in sap.ui.model.odata.v2.ODataModel