on 06-22-2023 10:17 AM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
It should be something like this to run it locally:
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: <patern for path>
destination: <your destination name>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi shubhmis ,
Thanks for providing solution, but I have tried your solution and I am getting similar 400 Error which I mentioned earlier
Here is my code in ui5.yaml:
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
Hi,
For testing in BAS, in URL of Ajax call use /Employees as the path
When you deploy it to BTP launchpad you have to change the URL. You can refer step 4 of this blog on how to call using app module path.
Calling External API In Custom Task UI of Workflow in Cloud Foundry | SAP Blogs
Thanks,
Shubham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For running locally in BAS, can you check the configuration in ui5.yaml file. In your local looks like you are passing a parameter test. Looking at your code it should have the below config there.
backend:
- path: /employees
destination: EmployeeDest
Also, generally, the content type is passed in the HTTP header than the data. Can you try removing that and running it on your server?
This is all assuming your destination URL is configured properly.
Thanks,
Shubham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi shubhmis
Thanks for responding. I have changed content type from data to HTTP header. My BTP destination URL is configured properly (checked connection with 200 Status Code). This is my ui5.yaml configuration:
specVersion: "2.6"
metadata:
name: com.yash.samplecrudui
type: application
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: false
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
- name: fiori-tools-appreload
afterMiddleware: compression
configuration:
port: 35729
path: webapp
delay: 300
- name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
component: com.yash.samplecrudui
ui5Theme: sap_horizon
ui5.yaml file does not have backend configuration like as you said. Does I need to define that backend configuration in ui5.yaml? Because when I tried with backend config I was not able run my app, showing you can not define backend configuration here in ui5.yaml. Please look into this.
Thanks.
User | Count |
---|---|
81 | |
11 | |
10 | |
7 | |
7 | |
6 | |
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.