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

Dear all,

I am experimenting in the Kyma environment and I would like to access an external OData-service (in this case one that is anchored in our C4C) in a Node.js-function. I can see and use the credentials saved in the environment variables, however, I am uncertain which JavaScript-function can be used in this environment to access the external source.

So far, my function looks like this. Upon contacting the API-Endpoint directing to this function, I receive my username of the C4C (as saved in the environment variables) and the unique entity-id as served by the C4C after firing the Event Notification.

module.exports = { 
  main: function (event, context) {
    // access to environment variables
    var oCredentials = JSON.parse(process.env.CONFIGURATION);
    var sUser = oCredentials.credentials.username;
    
    // make the incoming JSON readable by Node.js and select the Unique-ID (Entity-ID)
    var sEventData = event.data.replace(/-/g, '');
    var oEventNotification = JSON.parse(sEventData);
    var sEntityId = oEventNotification.data.entityid;
    return sUser + " " + sEntityId;
  }
}

If I simulate this code by sending a payload via Postman, I see, that I get the values I selected. My next step would be fetching the corresponding data with this entity-id from the OData Service. Is this possible in this manner?

Also, as you can see, my C4C is already recognized by the Kyma-environment:

All the best

Lucas Millbrodt

0 Likes
View Entire Topic
VishnAndr
Active Contributor
0 Likes