cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi Experts,

We have a requirement to consume a REST API in an SAPUI5 application developed in SAP Business Application Studio (BAS). I am able to consume ODATA service but for a REST API getting HTTP 404 error code, can you all please look at below scenario and help if I am missing out something. This is now on high priority any sort of help would be much appreciated.

Please note below:

I have create a FIORI app in SAP BAS having Target Runtime as Cloud Foundry and Using MANAGED APPROUTER, app id in manifest is ns.zzidexx2

Create a destination name "jsonplaceholder" in subaccount

Modified xs-app.json to include a route for redirection of API calls to destination

calling the REST API in view controller along with destination name

Tested the destination "jsonplaceholder" from BAS, it is working fine

-Regards,
Rauf Shaikh

View Entire Topic
MarcinGajewski
Explorer

Hi Rauf,

Please check following:

1. on your trial account -> go to subaccount -> menu Security on the left side -> Role Collections -> and make sure that at least Business_Application_Studio_Developer is attached to your user. If not - add it and restart BAS

2. go to BAS -> folder .vscode -> open launch.json. Mage sure if your config redirect properly to the destination on this line:

"env": { "run.config": "{\"handlerId\":\"fiori_tools\",\"runnableId\":\"/home/user/projects/project2_rest\"}", "FIORI_TOOLS_BACKEND_CONFIG": "[{\"path\":\"/jsonplaceholder\",\"destination\":\"jsonplaceholder\"}]" }

3. also take a look at Node Debug Console on backend, proxy and destination (should be jsonplaceholder in it)

Debugger attached.
info server:ux-proxy Starting fiori-tools-proxy using following configuration:
info server:ux-proxy proxy: 'http://127.0.0.1:8887'
info server:ux-proxy ignoreCertError: 'false'
info server:ux-proxy backend: [{"path":"/jsonplaceholder","destination":"jsonplaceholder"}]
info server:ux-proxy ui5: {"url":"https://ui5.sap.com","version":"","path":["/resources","/test-resources"],"directLoad":false}
info server:ux-proxy debug: 'false'
info server:ux-proxy Backend proxy started for /jsonplaceholder
info server:ux-proxy Used destination: jsonplaceholder
info server:ux-proxy UI5 proxy started for https://ui5.sap.com
info server:liveload Livereload middleware started for port 35729 and path /home/user/projects/project2_rest/webapp
Server started
URL: http://localhost:8080

4. and when you run the jQuery.ajax in Node Debug Console you will get something like this:

info server:ux-proxy Rewrite path /jsonplaceholder/posts > /destinations/jsonplaceholder/posts

this line is important because there can be route mistake like /destinations/jsonplaceholder/jsonplaceholder/posts

This is the pattern: /destinations/<destination name>/<service path>

adagli
Discoverer

Hi Marcin,

It worked for me. But after deploying to cloud foundry, I can not reach to the URL in the launchpad service.

How can I configure mta.yaml file for backend configuration or destination or routing for my URL from destination service?