Skip to Content

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

No 'Access-Control-Allow-Origin' header is present

Hi All,

         I am doing an AZAX call to AS400 Service From SAP UI5.

I am getting error :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:55756' is therefore not allowed access. The response had HTTP status code 400.

But if i disable web security for chrome using command.

Same service works fine.

Kindly suggest. How we can call this service without disable web security.

AJAX Source Code :

        $.ajax({

                             type : "GET",

                             contentType : 'application/json',

                             dataType : 'json',

                             crossDomain : true,

                             url : url,

                             headers: {

                            'api-key' : 'XXXXX',

                                 userId : 'XXXX',

                              password : 'XXX',

                              'Access-Control-Allow-Origin' : '*',

                             },

                           

                          //setRequestHeader("userId","JBRCTEST2")

                          success : function(response, status, request)

                             {

                            

                                  console.log(response);

                                  console.log(response.LookupResponse.Rows.Row.length);

                                  var oModel = new sap.ui.model.json.JSONModel(response.LookupResponse.Rows);

                                  that.getView().setModel(oModel);

                                 

                             },

                             error : function(jqXHR, textStatus,errorThrown)

                             {

                                    alert(" No success");

                             }

        });

Thanks

Vivek

Helpful Answer

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