Skip to Content
1
Sep 27, 2018 at 02:55 PM

Access REST API in Cloud Foundry App - Application Programming Model

943 Views

Hello,

I had a simple requirement to display data from Rest API(northwind) in a CloudFoundry application. But off course the actual work is never as simple as it sounds :) These are the steps I have performed, and hoping someone can help.

  • In SAP WEBIDE, Created a “SAP Cloud Platform Business application”
  • I did all the CDS configuration, and got the service to show up in application URL.
  • Created a destination to Northwind (name: CF_NORTHWIND) at the Subaccount level. Tested successfully.
  • Within the app, Now I want to call this Destination, and I’m doing it as following:

ODataQuery  testQuery = ODataQueryBuilder
        .withEntity("/V2/Northwind/Northwind.svc", "Products")
        .select("ProductID", "ProductName")
        .skip(1)
        .top(5)
        .inlineCount()
        .build(); 
ODataQueryResult result = testQuery.execute(“CF_NORTHWIND”);

Error in log:

"ERROR","categories":[],"msg":"Could not connect to destination service [No Access] :Failed to get destinations of subaccount: Failed to get access token for destination service. If your application is not running on Cloud Foundry, for example, when deploying to a local container, consider declaring the \"destinations\" environment variable to configure destinations." }

I have gone over the Official Help document numerous times, but I can’t seem to figure out what is missing.

I’ve also read that I have to create a instance of Destination and Xsuaa service at the App level. I’m not how these instances link to the SubAccount Destination?

Can someone please advise on what I could be missing? Any help would be appreciated.

Thank you,
Rob.