cancel
Showing results for 
Search instead for 
Did you mean: 

How to use REST API destination in SAP BTP and consume in UI5 application?

madhav15
Explorer
0 Kudos

Hello all,

I am developing UI5 application using SAP HANA Cloud Database and Spring boot API ( I deployed Spring boot app in Cloud foundry and deployed API working properly). I am getting issue while fetching API in UI5 application through ajax call. I am consuming API as a BTP Destination. following is my destination:

I am providing destination in xs-app.json:

I am calling API in ajax call. I have tried with absolute URL and relative URL both like /EmployeeDest/employees and EmployeeDest/employees, one is given in screen shot.

I am facing 404 issue while fetching API in UI5 application (without deploying):

And after UI5 app deployment I am getting 500 Error:

I have tried many solution and follow one blog, but nothing works.

Please guide me for issue.

Thanks.

View Entire Topic
madhav15
Explorer
Hi  shubhmis,

Thanks for responding. My problem has been resolved now. I have changed in ui5.yaml as you said and do more changes. Like in ui5.yaml file I changed as follows:

 customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
backend:
- path: /employees
destination: EmployeeDest

I changed my in xs-app.json as follows:

{
"source": "^/(.*)$",
"target": "/$1",
"destination": "EmployeeDest",
"authenticationType":"none"
},

And My ajax call URL is:

url: appModulePath + "/employees",

Since I am using Managed Approuter, I need to use App module path (In case of Standalone Approuter we use Application ID). I got app module path using this code:

              var appId = this.getOwnerComponent().getManifestEntry("/sap.app/id");
var appPath = appId.replaceAll(".", "/");
var appModulePath = jQuery.sap.getModulePath(appPath);

My problem is resolved using this configurations.

Thanks.

nsathya_infy
Explorer
0 Kudos

Hi Madhav,

Do you have sample code for this in any repo? 

I'm trying to call a CAP Service, which is successful but I have another destination which is a REST APi which is failing.

Thanks, 

Sathya