Skip to Content
Author's profile photo Nabheet Madan

Demystifying Hooks – SAP Cloud Platform Open Connectors – Part 2


In our previous blog we have seen how to develop a custom adaptor for Trello Dashboard. The response of the API call is returning us too much of a data whereas all we need is the name of dashboard and urls. So the next challenge was how to format the response. So in this blog we will see how we managed to trim down the response as per our needs via Hooks. If you remember when we created our adaptor in previous blog we did not implement any hooks, so let’s demystify how it works

Demystifying Hooks

Hooks are nothing but a way to modify you request or response via javascript code. The hooks can be called at different places such as global hooks in Setup tab which gets executed for all API calls, resource specific hooks which execute based on endpoints etc. for more basics read here. 

We will be implementing a hook at Endpoint level so that it modifies our endpoint response only.Go to Resources-> Choose your endpoint->Click edit -> Post Request Hook.

As can be seen on the right all the available fields are being shown here along with example code.Important thing while coding a hook is that, it must call in the end done method so as to signify the end of the script.

Now since we want only Board name and URL in the response, we can loop through the response body and construct a new response object.The code contains two different ways of doing the same thing one which i used to do earlier and another which i do now, courtesy DJ Adams functional programming, Thanks!

var updatedResponse =[];
var i = 0;
//My earlier way of doing things
// This is what functional progamming from DJ Adams does, Thanks sir!
var result = => ({ name:,url:resp.url }));


Call done function and passback the updated response as shown below.

     'response_body': result

Check if it works?

Choose already verified instance and request for the boards and validate the output Bingo it worked. We will keep on exploring further the other features and keep sharing the experience. Feel free to provide your feedback, open to all ears.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo DJ Adams
      DJ Adams

      The bit about functional programming and your use of map made my day. Thanks Nabheet!

      Author's profile photo Nabheet Madan
      Nabheet Madan
      Blog Post Author

      Thanks sir...feeling is mutual:)