cancel
Showing results for 
Search instead for 
Did you mean: 

MTA on Cloud Foundry: using (none odata) web service via basic authentication

06-23-2021 4:25 PM
1068 views 2 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello everyone,

an application, which is host on SCP Cloud Foundry, should call a (none odata) web service to upload something. The destination of the web service is configured via BTP cockpit (subaccount --> Connectivity --> Destinations) and had the following properties:

  • Name: test-dest
  • Type: HTTP
  • Description: test web service
  • URL: https://test-web-service.com
  • Proxy Type: Internet
  • Authentication: BasicAuthentication
  • User: {TECHNICAL_USER}
  • Password: *******

When starting the application outside the fiori launchpad (subaccount --> HTML5 Applications), the web service is mapped properly and the request is send successfully.

When starting the application embedded in the fiori launchpad, the web service is NOT mapped properly and the request failed.

xs-app.json:

{
    "routes": [{
            "source": "^/file-upload",
            "target": "/{web-service-upload-subpath}",
            "destination": "test-dest",
            "authenticationType": "basic"
        }
    ],
...
} 

sending test request via fetch api:

 _sendTestRequest: function () {
     fetch("/file-upload")
     .then(...)
     .catch(...);
  }

When sending this request via application embedded in the fiori launchpad, the request failed (403 Forbidden).

The request URL is:

https://{LAUNCHPAD_ID}.hana.ondemand.com/file-upload

When modify the URL via debugger, the following request is send successfully

https://{LAUNCHPAD_ID}.hana.ondemand.com/{APP_ID}/file-upload

This should be the proper URL.

An ugly workaround to solve this problem is to define a v2 ODataModel in the manifest.json based on a data source with the uri "/file-upload". Of course the "/$metadata" request will be failed, because the web service is not a odata service. But the ODataModel instance member "sServiceUrl" holds the request path and can be used.

Now I ask myself if I must define a multi target application destination service via mta.yaml. I had try a lot of mta.yaml configuration, but nothing has worked.

Maybe you can help me.

Thanks!

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
SAP Mentor
SAP Mentor

Please check the solution I've found for a similar issue: Calling Service using AJAX in Fiori Elements Extension doesn't work in Launchpad

0 Likes

Thanks Gregor. The workaround

this.getOwnerComponent().getManifestObject().resolveUri({URI})

works perfectly!

Answers (0)