Forum Discussion

Rahamath's avatar
7 years ago

pull list of services under a group

Hello,

Is there a method to pull all the services [websites] from a group ?

I have created a group "TEST" under services, and added 50 websites for monitoring, I need to pull a list of services from TEST group. thanks

1 Reply

Replies have been turned off for this discussion
  • Hi Rahamath,

    You can accomplish this by using the REST API endpoint "/service/services" along with filtering on the "serviceFolderId" property.

    See "Example 1" on this page and notice how its JSON output contains "serviceFolderId".

    {
      "status" : 200,
      "errmsg" : "OK",
      "data" : {
        "total" : 5,
        "items" : [ {
          "type" : "webservice",
          "id" : 58,
          "name" : "Form-based auth",
          "description" : "",
          "serviceFolderId" : 1,
          "stopMonitoring" : false,
          "stopMonitoringByFolder" : false,
          "disableAlerting" : false,
          "individualSmAlertEnable" : false,
          "individualAlertLevel" : "warn",
          "overallAlertLevel" : "warn",
          "alertStatus" : "none",
          "sdtStatus" : "none-none-none",
          "alertDisableStatus" : "none-none-none",
          "pollingInterval" : 10,
          "transition" : 1,
          "testLocation" : "{\"smgIds\":[3],\"all\":false}",
          "globalSmAlertCond" : 0,
          "useDefaultLocationSetting" : false,
          "useDefaultAlertSetting" : false,
          "userPermission" : "write",
          "checkpoints" : [ {
            "id" : 292,
            "geoInfo" : "Overall",
            "smgId" : 0
          }

    You'll want to execute the same REST API query as Example 1 (with your own credentials) and check the output to find at least one service in your desired service group. Note your output's numeric value for "serviceFolderId" because you'll need to execute the query again filtering on that ID.

    Now look at "Example 2" on the same page for an example of using query parameters. In this example, the query parameter is "fields" but you need to use the query parameter of "filter". You can use the code in Example 2 but change the credentials and the query parameters. To change the query parameters find this line code:

    queryParams = '?fields=id,name,host,alertStatus&sort=-alertStatus'

    Change that line of code to:

    queryParams = '?filter=serviceFolderId:1'

    You will need to replace the number 1 with whatever serviceFolderId you found by running first query from "Example 1".

    If you're still having trouble, don't hesitate to use our 24/7 chat support! You can also post your code here for better help troubleshooting.