Failed to load resource while consuming OData service

Naoto Amari

Hello comunnity i need some help, i have my odata service already running and i have an url like this:

https://myclient:port/sap/opu/odata/SAP/servicename_SRV/MaterialListSet

This is my config, which I suppose is wrong.

manifest.json

"dataSources": {
   "invoiceRemote": {
      "uri": "https://myclient:port/sap/opu/odata/SAP/servicename_SRV/",
      "type": "OData",
      "settings": {
      "odataVersion": "2.0"
      }
   }
}
.
.
.
"models": {
...
   "invoice": {
      "dataSource": "invoiceRemote"
   }
}

I get these two errors:

Failed to load resource: the server responded with a status of 401 (Unauthorized)

and

Failed to load https://client:port/sap/opu/odata/SAP/odata_SRV/$metadata?sap-language=ES: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:port' is therefore not allowed access. The response had HTTP status code 401.

fabiopagoti

This line is not good;

"uri": "https://myclient:port/sap/opu/odata/SAP/servicename_SRV/",

This is because you have to use relative URLs, so it should be

"uri": "/sap/opu/odata/SAP/servicename_SRV/",

The reason behind that is simple: your customer for sure has more than one SAP Gateway/Fiori system. So you shouldn't hard code the domain of your development or production system.

Assuming you will eventually deploy your UI5 application to the SAP NetWeaver system, then that system will contain both the oData service AND the UI5 application. And as they will be hosted in the same server, relative URLs will work just fine.

However inside Web IDE this is not enough because if you use relative URLs than SAP Cloud/Web IDE will understand that you are trying to access a resource in the cloud.

That is why you should add/change your neo-app.json file inside your UI5 project. If you have it already than just change it. If you do not have this file inside your project yet, you can easily create it by right-clicking in the project name and choosing New >> HTML5 Application Descriptor. This will create this file in the root of your project. (outside the webapp folder usually present).

Finally, you will have to add a route in this neo-app.json file, like this

{
  "path": "/sap/opu/odata",
  "target": {
    "type": "destination",
    "name": "NAME_OF_YOUR_SAP_CLOUD_DESTINATION",
    "entryPath": "/sap/opu/odata"
  },
  "description": "SAP Gateway System"
}

This tells Web IDE to forward every request to a different system under the destionation specified.

This will only work if you have in place an SAP Cloud Connector linking your SAP Cloud account with your SAP NetWeaver on premise system.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Service worker Failed to load resource: net::ERR_INTERNET_DISCONNECTED

From Dev

Service worker Failed to load resource: net::ERR_UNSAFE_REDIRECT

From Dev

Error when consuming OData service - There is a type mismatch between the client and the service

From Dev

Failed to load .js resource

From Dev

Failed to load resource in HTML

From Dev

Glide failed to load resource

From Dev

GlideException: Failed to load resource

From Dev

IDEA Failed to load resource

From Dev

HTTP load failed while getting data from the service

From Dev

UnKnowHost Exception while consuming a web service

From Dev

Chrome give error **Failed to load resource: net::ERR_NAME_NOT_RESOLVED** while other browser load images

From Dev

Failed to load resource:Frame load interrupted in Safari browser while downloading multiple files

From Dev

Failed to load resource in AngularJS project

From Dev

Failed to load resource with Websocket application

From Dev

Failed to load resource in Node JS

From Dev

Angular and html - Failed to load resource

From Dev

GitHub Pages Failed to load resource

From Dev

Suppress Load of media resource failed

From Dev

iframe on Safari: Failed to load resource

From Dev

Failed to load resource, blank page

From Dev

Credential Error while consuming the WCF Service hosted in Azure App Service

From Dev

The socket connection was aborted while consuming wcf service in windows service

From Dev

Failed to load resource: the server responded with a status of 503 (Service Unavailable) favicon.ico

From Dev

service worker android Failed to load resource: net::ERR_INSECURE_RESPONSE

From Dev

Getting 413 "Failed to load resource: the server responded with a status of 413 ()" while uploading file to Dropbox

From Dev

Getting Failed to load resource 404 error while uploading file via AJAX

From Dev

fetch 404 while loading jpg Failed to load resource: the server responded with a status of 404 ()

From Dev

Consuming OData from Eclipse

From Dev

Getting null value while consuming wcf service in c#

Related Related

  1. 1

    Service worker Failed to load resource: net::ERR_INTERNET_DISCONNECTED

  2. 2

    Service worker Failed to load resource: net::ERR_UNSAFE_REDIRECT

  3. 3

    Error when consuming OData service - There is a type mismatch between the client and the service

  4. 4

    Failed to load .js resource

  5. 5

    Failed to load resource in HTML

  6. 6

    Glide failed to load resource

  7. 7

    GlideException: Failed to load resource

  8. 8

    IDEA Failed to load resource

  9. 9

    HTTP load failed while getting data from the service

  10. 10

    UnKnowHost Exception while consuming a web service

  11. 11

    Chrome give error **Failed to load resource: net::ERR_NAME_NOT_RESOLVED** while other browser load images

  12. 12

    Failed to load resource:Frame load interrupted in Safari browser while downloading multiple files

  13. 13

    Failed to load resource in AngularJS project

  14. 14

    Failed to load resource with Websocket application

  15. 15

    Failed to load resource in Node JS

  16. 16

    Angular and html - Failed to load resource

  17. 17

    GitHub Pages Failed to load resource

  18. 18

    Suppress Load of media resource failed

  19. 19

    iframe on Safari: Failed to load resource

  20. 20

    Failed to load resource, blank page

  21. 21

    Credential Error while consuming the WCF Service hosted in Azure App Service

  22. 22

    The socket connection was aborted while consuming wcf service in windows service

  23. 23

    Failed to load resource: the server responded with a status of 503 (Service Unavailable) favicon.ico

  24. 24

    service worker android Failed to load resource: net::ERR_INSECURE_RESPONSE

  25. 25

    Getting 413 "Failed to load resource: the server responded with a status of 413 ()" while uploading file to Dropbox

  26. 26

    Getting Failed to load resource 404 error while uploading file via AJAX

  27. 27

    fetch 404 while loading jpg Failed to load resource: the server responded with a status of 404 ()

  28. 28

    Consuming OData from Eclipse

  29. 29

    Getting null value while consuming wcf service in c#

HotTag

Archive