0

I have trouble getting the mock server to work. I have set up everything according to the SAPUI5 guide provided here, but when I launch the application using mock server ("/test/mockServer.html") it gives me error in console:

Uncaught (in promise) Object {message: "HTTP request failed", request: Object, response: Object, statusCode: 404, statusText: "Not Found"…}

What could be the problem? I have tryed simulating the service with mockDataUri or just with the metadata uri, but either way the result is the same. I also tried to run the mockServer.html from Web IDE, but it didn't change anything.

EDIT: it seems that the problem is about how to use the mock server not the server itself, because mock server contains data, but I can't get the data to model. Example:

// Create Mock Server
var oMockServer = new MockServer({
    rootUri: rootUri
});
...
oMockServer.getEntitySetData("Entity") // Returns generated mock data
...
// Create Model
var oModel = new sap.ui.model.odata.ODataModel(rootUri, true);
dataModel.read("Entity", null, null, true, function (oData, oResponse) {
    console.log(oData, oResponse);
}, function (oError) {
    console.log(oError); // logs Object {message: "HTTP request failed", request: Object, response: Object}
});

What could be the problem?

niceman
  • 251
  • 3
  • 16
  • Does this answer your question? [UI5 Mock Server with Local Data: "rootUri" Not Working](https://stackoverflow.com/questions/46664672/ui5-mock-server-with-local-data-rooturi-not-working) – Boghyon Hoffmann Jul 12 '21 at 15:27

1 Answers1

0

rootUri shouldn't contain "https:// this.kinof.url / myService /". Use only "/myService/" instead.

niceman
  • 251
  • 3
  • 16
  • Also there are some other rules to watch out for. Take a look at the answer here: https://stackoverflow.com/a/47181847/5846045 – Boghyon Hoffmann Nov 08 '17 at 14:26
  • @niceman yes this works if I change the `uri` in the manifest.json of my datasource but I thought that was the purpose of a mockserver. You call `https://something.com/service` and put this in the `rootUri` of the mockserver. And then I can call this. Why does this not work? Thanks in advance! – Thunermay Oct 25 '22 at 10:20