cancel
Showing results for 
Search instead for 
Did you mean: 

Use Subaccount destination from SCP SDK requestBuilder

0 Kudos

Hi all,

I've done this tutorial and thought it would be great to run it against one of my Successfactors systems instead of S/4.

Since SF does not have any ready to use API, I generated my own VDM using this tutorial. In my cf global account i connected my SF tenant as a system, which creates a ready to use destination in my subaccount.

In my requestBuilder, I would now like to use this destination, but it won't let me. The error I get is:

019-11-15T14:36:35.94+1100 [APP/PROC/WEB/0] ERR Environment variable 'destinations' is set. Destinations will be read from this variable. This is discouraged for a productive application! Unset the variable to read destinations from the destination service on SAP Cloud Platform.
   2019-11-15T14:36:35.94+1100 [APP/PROC/WEB/0] ERR Unable to build destination for service binding: Unable to find a service binding for given name "sfdemo"! Found the following bindings: myuaa.
   2019-11-15T14:36:35.94+1100 [APP/PROC/WEB/0] ERR Unable to match a specific XSUAA service instance to the given JWT. The following XSUAA instances are bound: myapp!t594. The following one will be selected: myapp!t594. This might produce errors in other parts of the system!
   2019-11-15T14:36:35.94+1100 [APP/PROC/WEB/0] ERR Service 'destination' not found in 'VCAP_SERVICES'.
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR (node:81) UnhandledPromiseRejectionWarning: Error: Could not find a destination with name "sfdemo"! Unable to execute request.
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at Object.errorWithCause (/home/vcap/app/node_modules/@sap/cloud-sdk-util/dist/error.js:14:20)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at /home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/request-builder/request-builder-base.js:125:78
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at process._tickCallback (internal/process/next_tick.js:68:7)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR Caused by:
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR Error: No binding to a Destination service instance found. Please bind a destination service instance to your application!
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at getDestinationServiceCredentials (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:394:15)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at getAccessToken (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:327:60)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at /home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:172:42
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at step (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:46:23)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at Object.next (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:27:53)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at /home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:21:71
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at new Promise (<anonymous>)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at __awaiter (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:17:12)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at getDestinationFromDestinationService (/home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:149:12)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR     at /home/vcap/app/node_modules/@sap/cloud-sdk-core/dist/scp-cf/destination-accessor.js:131:107
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR (node:81) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
   2019-11-15T14:36:36.04+1100 [APP/PROC/WEB/0] ERR (node:81) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here is my call. In the ts description of the requestBuilder it describes the jwt is mandatory when using subaccount destinations. How do I retrieve the jwt and pass it here? Does anyone have a piece of documentation on how to use subaccount destinations from a node app?

  var req = Candidate.requestBuilder()
    .getAll()
    .top(20) //look at the top 20 candidates only
    .select(Candidate.FIRST_NAME, Candidate.LAST_NAME)
    .execute({
      jwt: ?????,
      destinationName: 'sfdemo'
    });

    return req
}
View Entire Topic
0 Kudos

For others trying to figure this out, a few days ago a great series of tutorials has been released on this topic.

Check it out here.