Skip to Content

SAPUI5 sends a OPTIONS HTTP Request Method instead of GET

Hi,

We are developing a application using SAPUI5 Development Kit ver 1.12. The Data is obtained from a Netweaver Gateway system. When the SAPUI5 Framework instantiates the ODataModel Object it attempts to make a connection to the URI which has been specified in the URL.

In Chrome ver 27, when the oDATAModel Object is instantiated, this leads to a OPTIONS request going to the Netweaver Gateway. i.e. the Request Method in the HTTP Header is OPTIONS and not GET or PUT. This OPTIONS request fails with HTTP error code 401, Unauthorized.

The oData Service requires Authentication before it can be used.

We are passing the Username and password while creating the oDataModel Object, i.e. in its constructor. Also our Sync is not Asynchronous.

The JS code snippet from the View is given below

var oDATAServiceURL = "http://server/ias_relay_server/client/rs_client.dll/ODATAFARM/sap/opu/odata/sap/Z_OURSERVICE";var oDATAServiceUserName = "NetWeaverGatewayUserID";var oDATAServicePassword = "PasswordOfNetWeaverGatewayUserID";var myODATAModel = new sap.ui.model.odata.ODataModel(oDATAServiceURL, false, oDATAServiceUserName, oDATAServicePassword, null);

Can anybody let me know what do I have to do to resolve this issue?

_______________________

Regards

Amardeep Verma

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on May 31, 2013 at 08:39 AM

    Hi ,

    In New Version of SAPUI5 use the format shown below .

    oDATAServiceURL = "proxy/http/server/ias_relay_server/client/rs_client.dll/ODATAFARM/sap/opu/odata/sap/Z_OURSERVICE";

    For More Information :

    http://scn.sap.com/thread/3215471

    Regards,

    Jibin Joy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 27, 2013 at 09:17 AM

    Hi Amardeep,

    Take a look at the link below where it explains the "preflighted" requests.

    "preflighted" requests first send an HTTP OPTIONS request header to the resource on the other domain, in order to determine whether the actual request is safe to send. Cross-site requests are preflighted like this since they may have implications to user data

    https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Prabhuarul,

      Your application on the server side must be able to handle the OPTIONS http method and return the http response header "Access-Control-Allow-Origin" defining which origin is allowed to access your application via CORS (cross-origin resource sharing).

      You can find more information about this here.

      Regards,

      Christian

  • Posted on Mar 15, 2016 at 01:54 PM

    Hi All,

    Anyone knows how to solve this.

    I'm having the same issue. I already disabled all the security in Chrome, but still not able to understand what is happening.

    Any suggestions?

    Thanks,

    Ricardo Fuzeta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 12, 2016 at 03:58 AM

    Hi Friends,

    I am using an URL :

    https://s10hanaxs.hanatrial.ondemand.com/i322345trial/hanatrialinstance/test2/test2.xsodata

    This is a HTTPS url. I am also getting the same error when I use

    new sap.ui.model.odata.ODataModel("https://s10hanaxs.hanatrial.ondemand.com/i322345trial/hanatrialinstance/test2/test2.xsodata");

    Its sending OPTIONS request. Can any one help me ASAP for this.

    I am using Trial HCP account.

    Regards &Thanks

    Nishant

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.