on 09-09-2021 6:44 AM
Hi Experts,
I am doing a proof of concept solution with the Northwind Odata service
I am able to access and run the App from within Business Application Studio, but the same App when I deploy to Cloud Foundry and run through Fiori Launchpad, it fails to access service
In manifest.json
"sap.app": {
...
"dataSources": {
"mainService": {
"uri": "Northwind",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
...},
"sap.ui5" {
...
"models" : {
...
"": {
"dataSource": "mainService",
"preload": true
}
}
...
}
In Init method of controller
var odataModel = new sap.ui.model.odata.v2.ODataModel("V2/(S(legz422e3rqzkbmllbn2l1jx))/OData/OData.svc/");
odataModel.read("/Products",{
error: function(oError){
MessageBox.error("Error");
}
});
this.getView().setModel(odataModel);
In xs-app.json I have tried adding this with no benefit
...
"routes": [
...
{
"source":"^/Northwind/(.*)$",
"target": "$1",
"destination":"Northwind",
"csrfProtection":false,
"authenticationType":"none"
}
...
From Fiori Launchpad, it tries to call the below URL but fails (404 error)
https://6d454a5atrial-ea.launchpad.cfapps.eu10.hana.ondemand.com/destinations/Northwind/V2/(S(legz42...
What am I missing?
It seems to me that you call the wrong URL. There is no such endpoint as https://6d454a5atrial-ea.launchpad.cfapps.eu10.hana.ondemand.com/destinations/Northwind.
When using the managed approuter (provided by the Launchpad service), you need to make use a URLs that are relativ to the application URL. Please read this post here for all the details (at least the second that is about relative and absolute URLs).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I maintained the relative URL as mentioned in the now these two are failing during App load:
Status Code:
403 Forbidden
The request has been blocked by UCON.
and
Status Code:
404 Not Found
My datasource now look like:
"sap.app":
{...
"dataSources":
{
"mainService":
{
"uri": "V2/(S(legz422e3rqzkbmllbn2l1jx))/OData/OData.svc/",
"type": "OData",
"settings":
{
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},...},
Update:
After tweaking with my xs-app.json, I was able to get one of the metadata call work:-
https://
.
launchpad.cfapps.eu10.hana.ondemand.com/6d1255ea-fccb-4c07-bf65-dafcc9515033.sap-btp-crudapp.sapbtpc...
Now works!
But still there is one more call:-
Gives 404 not found
My xs-app.json now look like this
{
"welcomeFile": "/index.html",
"authenticationMethod": "route",
"routes": [
{
"source": "^/V2/(.*)$",
"destination": "Northwind",
"authenticationType": "none",
"csrfProtection": false
},
{
"source": "^/V2/(.*)$",
"target": "/V2/$1",
"destination": "abap-cloud-default_abap-trial",
"authenticationType": "xsuaa",
"csrfProtection": false
},
{
"source": "^/resources/(.*)$",
"target": "/resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^/test-resources/(.*)$",
"target": "/test-resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^(.*)$",
"target": "$1",
"service": "html5-apps-repo-rt",
"authenticationType": "xsuaa"
}
]
}
Everything but the Northwind route was auto-generated. Strangely, the Northwind route when put at the end does not work. The abap-cloud-default_abap-trial route was auto-generated. I though the Northwind route was conflicting with the source path of the abap-cloud-default_abap-trial route. But removing the abap-cloud-default_abap-trial route makes no difference.
You are right, both rights are in conflict as they match the same source pattern. The approuter will always match the first route, which is why it doesn't make a difference when you remove the second route. The solution is to provide more specific source expressions to differentiate both routes. Here's the docu of the approuter to find out how routing works in details.
PS: It's strange that your web app sends a request to ".../cp.portal/...". I think this should happen either.
Hi Marius,
I discovered the problem of the second call with cp.portal was being caused by the explicit read statement in the controller
var odataModel = new sap.ui.model.odata.v2.ODataModel("V2/(S(legz422e3rqzkbmllbn2l1jx))/OData/OData.svc/");
odataModel.read("/Products",{
error: function(oError){
MessageBox.error("Error");
}
});
this.getView().setModel(odataModel);
As soon as I removed it, the App ran fine form Fiori Launchpad. This worked as the Northwind ODS is the default model.This is good enough for me now.
But question remain what if I had to explicitly read a model which is not the default model? To test, I created the changed the endpoint in the above code snippet to "V2/Northwind/Northwind.svc/" and created its corresponding entries in manifest.json and the same error with cp.portal returned.
User | Count |
---|---|
80 | |
10 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.