cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error 403 forbidden in put method when running on android

10-28-2014 1:49 PM
627 views 5 comments
0 Likes
SAP Managed Tags
Subscribe

hi experts,

We have create JQM application. We are using odata services and we are authenticating the odata services through SMP. When we running the app on browser its working fine. We used phonegap container and made .ipa and its working fine on ipad. But when we are creating .apk using phonegap container its giving 403 forbidden error for put and post methods on android devices.

     We have passed 'X-CSRF-TOKEN' to put and post methods. There is no error in SMP logs. There is no runtime error in gateway system.

Can anyone have any idea why its happening??

Thanks in advance.

Regards,

Supriya

0 Likes

Accepted Solutions (0)

Answers (3)

Answers (3)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Likes

Were you able to find the solution?

Former Member
0 Likes

hi,

Actually neither SMP nor netweaver gateway is giving any error. and this app is working fine on ipad and browser.

I have posted Put method code which i have written.

                                                       .ajax({

                                                                    headers : {

                                                                        "X-SUP-DOMAIN" : "DomainName",

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

                                                                        "Content-Type" : "application/json",

                                                                        "DataServiceVersion" : "2.0",

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

                                                                        "X-CSRF-Token" : header_xcsrf_token,

                                                                        "X-SUP-APPCID" : CookieIdCreate,

                                                                        "Access-Control-Allow-Origin": "*"

                                                                    },

                                                                    type : "PUT",

                                                                    url : newurl,

                                                                    dataType : "json",

                                                                    data : dataFinal,

                                                                    username :userName,

                                                                    password :passWord,

                                                                    cache:false,

                                                                    //crossDomain: true,

                                                                    async :false,

                                                                    Timeout:50000,

                                                                    success : function(jqXHR,

                                                                            textStatus, errorThrown) {

                                                                                alert("success");}

                                                                  error : function(jqXHR,

                                                                            textStatus, errorThrown) {

                                                                                alert("error" +jqXHR.status);}

                              });

Can anyone help me in figure out actual error??

Thanks in advance,

Regards,

Supriya

Former Member
0 Likes

Dear Supriya,

The error looks like authorization issue. Kindly refer below ajax call format.

$.ajax({

               type: "POST",

               contentType: "application/atom+xml; charset=utf-8",

               beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Basic ' + btoa(usr + ":" + pwd)); },

               dataType: 'xml',

               crossDomain: true,

               data: datatopost,

               async: true,

               timeout: 40000,

               url: "https://mysap/sap/opu/odata/sap/ZSALESORDERDEMO_SRV/SOHeaders",

               complete: function () {

               },

               success: function (json) {

                   console.log(json);

                  

                  // alert("sucess");

                   data1 = $(json).find('id').eq(0).text();

                  

                   data2 = data1.split("'");

                   alert("The sales order :" +data2[1]+" is created successfully");

                  

            

               },

               error: function (jqXHR, textStatus, errorThrown) {

                   alert("failure: " + errorThrown + " " + textStatus);

                   alert(error.innererror.errordetails[0].message);

                   $.mobile.loading("hide");

               }

Former Member
0 Likes

This message was moderated.

0 Likes

Hi Supriya,

Which server does return the HTTP 403, is it the SMP server or the oData Service?

Cheers,
Mohamed