Pull Catchpoint Data into Google Docs with New API
Catchpoint's new API now allows you to pull Catchpoint data into Google Docs using Google Apps Script. Read more for a step-by-step guide to learn how.
Google Apps Script allows you to programatically create and modify Google Docs, as well as customize the user interface with new menus, dialog boxes, and sidebars.
Here, we will walk you through how to pull Catchpoint data into Google Sheets using Apps Scripts.
Firstly, you will need to configure the Catchpoint Pull API in the portal. Login into the Catchpoint Portal and head to Settings -> API.
Set the Pull API to Active and click Add Consumer. Complete the form by providing a Name and a Contact, you do not need to configured Allowed IPs. Click Save. This will generate a Key and a Secret that you will need when building your Google Apps Script.
Next, you will need to have a Google account and sign into Google Docs – http://docs.google.com. Once signed in create a new Sheet. In the Sheet menu goto Tools -> Script Editor
Under Create script for select Blank Project. The editor will load with a skeleton script (Code.gs) and function called myFunction()
Change of the name of this function to ‘onOpen()’ this will cause the function to run when the spreadsheet is opened.
Next, configure the variables that will be used to make the initial call to get the authentication token. This token is required to make calls to the Catchpoint Pull API. More details can be found in the documentation – http://io.catchpoint.com. In the code below replace ‘your_key’ and ‘your_secret’ with the Key and Secret you created in the Catchpoint portal.
Once the options have been configured you need to make the call to the token URL, parse the JSON response returned and base64 encode the returned token.
With the token now stored in the correct format we are ready to make a call to the API. In this example we will fetch a list of current tests running in Catchpoint.
The following code will pass the token to the API and return a JSON response containing the running tests.
Next, configure the script to use the current active sheet in Google Docs.
Next, the returned JSON data needs to be parsed and pushed into the sheet along with column headings.
You are now ready to save the script and test. Save the project and enter project name.
Click the Run icon, at which point Google will request authorization for the app to run.
Accept this request. The app will then run. Jump back to your spreadsheet and you will see it has been populated with a list of tests.
This is just a basic example of getting the integration working. The above could be worked on to honour token expiration and refresh, additional functions to pull other API data into sheets, create graphs with test data etc.
The above skeleton is a great start to manipulating and visualising Catchpoint Data in Google Docs. Enjoy!