Scripting Recipe Catchpoint REST API Transaction

Prev Next

Objective

This article will give you an example of how to create an API transaction script to access the Catchpoint Rest API.

Prerequisites

Process

  • Login to the portal.
  • Create an API transaction test.
    Pic_7.png
  • Copy/paste the script given below to the script editor.
    Pic_8.png
  • Click Save

Script:

NOTE:You will need to change the key and secret values to point to a different account.

// Step - 1
open("https://io.catchpoint.com/ui/api/token")
setNavigatePostData("grant_type=client_credentials&client_id=<ClientIDHere>&client_secret=<ClientSecretHere>")
var token = ${extract('resp-content','regexp:access_token":"([a-zA-Z0-9]+\S+)"')}; var tokenEncoded = ${base64("${var(token)}")};

// Step - 2
//The request will pull the nodes' information
open(https://io.catchpoint.com/ui/api/v1/nodes)
setHeader("authorization", "Bearer ${var(tokenEncoded)}")