cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind a non-oData destination in SAP BAS for local development?

boolan
Participant
0 Kudos

Hi,

I have the following problem:

I cannot reach a non-oData destination from the sapui5 app developed in SAP BAS.

The requests are not routed to the destination in SAP BAS, but they are routed when the app is deployed in SAP BTP.

I have defined the following non-OData destination in BTP:

When I deploy the app to SAP BTP, the AJAX requests to this destination are correctly routed and data is retrieved.

But they are not routed in the SAP BAS when I want to test the app during development.

I tried to bind this destination using Run Configuration:

I can select this destination using Run Configuration option, then Connect to SAP system...

but when I pick the WeatherAPI, and run the application:

the requests are not routed to the destination. The same app works correctly when deployed in BTP.

How should I correctly bind the destination in SAP BAS?

With best regards,

Krzysztof Bulanowski

gregorw
Active Contributor
0 Kudos

Would be interresting what you see in the Payload tab.

boolan
Participant
0 Kudos

In the payload tab you see the query string parameters:

And here is the git repo link:

https://github.com/boolan/btpweather.git

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

Hi there!

What is the complete URL you are trying to reach? I can see the /Weather/ in the request (the source of your route in the xs-app.json) - is that supposed to be there?

gregorw
Active Contributor
0 Kudos

There is one more thing. You should not put the API key into your source. I've found the documentation Passing Information to the Backend Using a Destination which describes that in the destination an additional parameter:

sap.query

could be set to the value:

appid=<API key>

I've tested that but it seems that this has no effect. Will file an SAP Incident tomorrow.

gregorw
Active Contributor

I've filed now the incident 845657 / 2021. But maybe this is not directly an issue with the Destination Service but with the ui5 tooling proxy that does not respect this parameter. In the deployed version the approuter or managed approuter should handle this parameter.

Maybe mariusobert or vobu have some input in this direction.

boolan
Participant

Hi Gregor,

Thank you for following up on this topic.

I will check if the destination with parameters works correctly with the app deployed in SAP BTP on my side.

Definitely they should not be exposed in the code.

I think the ui5 tooling deserves a fresh blog or at least a more detailed documentation.

Here is one which I have found:

https://blogs.sap.com/2020/04/07/ui5-tooling-a-modern-development-experience-for-ui5/

Also I am going to write a blog in the next days in which I will describe the efforts to create this weather app and get working. Such an E2E description might be useful.

With best regards,

Krzysztof.

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor

Hi Krzysztof,

first I would suggest that you learn some more basics for SAPUI5 and start with the Walkthrough and learn about Step 7: JSON Model.

To avoid not needed requests you should remove:

            "mainService": {
                "uri": "/sap/opu/odata/",
                "type": "OData",
                "settings": {
                    "annotations": [],
                    "localUri": "localService/metadata.xml",
                    "odataVersion": "4.0"
                }
            },

and:

,
            "": {
                "dataSource": "mainService",
                "preload": true,
                "settings": {
                    "synchronizationMode": "None",
                    "operationMode": "Server",
                    "autoExpandSelect": true,
                    "earlyRequests": true,
                    "groupId": "$direct"
                }
            }

from the manifest.json.

To fix the issue with the API connection you should replace:

          - path: /sap 
            url: http://localhost

with:

          - path: /Weather
            pathPrefix: /
            url: https://api.openweathermap.org
            destination: WeatherAPI

in the ui5.yaml.

And finally replace test/flpSandbox.html with index.html in the package.json start script.

I've then got this result:

CU
Gregor

former_member832646
Discoverer
0 Kudos

Hi Gregor Wolf,

I have application where i am calling third party API. I am able to connect to API and get response when deployed it to CF but not able to run it locally. It gives me error 404.

I have changed path in ui5.yaml file already

image.png

Also binding my Destination for API in local BAS is done

This is what i have in menifest.json for datasource and model section.

"dataSources": { "mainService": { "uri": "gvp/Public", "type": "OData", "settings": { "annotations": [], "localUri": "localService/metadata.xml", "odataVersion": "2.0" } } } "models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "testrailapi.i18n.i18n" } }, "": { "dataSource": "mainService", "preload": true, "settings": {} } },

can you please help here with what else we need to do to make it work locally in business application studio (BAS).

Regards,

Chaitali Desai

Answers (0)