Articles in this section
Category / Section

Managing Data Source Threshold Property in Bold BI REST API

Published:

When creating data sources with Bold BI through its REST API, one of the properties you can configure is the ThresHold property. This property is applicable only for Code View mode and determines whether a threshold is applied to the data source, limiting the amount of data fetched based on the specified ThresHoldDataLimitValue.

Obtain Access Token:

To start, you need to authenticate with the Bold BI server and obtain an access token. Use the following JSON structure in a tool like Postman, replacing your Bold BI_username and Bold BI_password with your actual Bold BI credentials.

Endpoint:

http://localhost:55057/bi/api/site/site1/token

Request sample:

    {
      "username": "Bold BI_username",
      "password": "Bold BI_password",
      "grant_type": "password"
    }

Select the POST method and send the request to receive your access token.

image.png

Steps to Create a Data Source Via API

1. Obtain the API Endpoint

The first step is to get the API endpoint for creating a data source. The endpoint typically looks like this:

https://<boldbi_domain>/api/site/site1/v4.0/datasources

Replace <boldbi_domain> with the domain where your Bold BI instance is hosted.

http://localhost:55057/bi/api/site/site1/v4.0/datasources

2. Send the API Request

Send a POST request to the API endpoint with the JSON and the token for authorization.

Syntax:

{
  "Name": "string",
  "Type": "string",
  "Description": "string",
  "Connection": {}
}

Make sure to replace the connection string and other details with the actual information for your data source.

Request Sample

    {
      "Name": "SQL-Test",
      "Type": "sqlserver",
      "Description": "",
      "Connection": {
        "Servername": "localhost",
        "Query": "SELECT * FROM [dbo].[Orders] AS [Orders]",
        "IntegratedSecurity": false,
        "Username": "username",
        "Password": "password",
        "Database": "dbname",
        "Schemaname": "dbo",
        "Tablename": "Orders",
        "Impersonate": false,
        "AdvancedSettings": "",
        "IsEnableSSL": false,
        "CommandTimeout": 300,
        "IsSshConnection": false,
        "SshServerName": "",
        "SshPort": 0,
        "SshUsername": "",
        "SshPassword": ""
      }
    }

4. Handle the Response

After sending the request, you will receive a response from the server. If the data source is created successfully, the response will include details of the newly created data source.

image.png

If the query is included in the connection properties, the data source will be generated in code view mode. To create the data source in design mode, remove the line containing the query and send the request. It is important to remember that when creating the data source in design mode, the threshold option cannot be selected as it is only available in code view mode. For the design mode, we have options like: Data Sampling

Guidelines for modifying the threshold setting Via API:

    {
      "Name": "string",
      "Type": "string",
      "DataSourceId": "string",
      "Description": "string",
      "Connection": {
      "Servername": "localhost",
        "Query": "Your_Query",
        "IntegratedSecurity": false,
        "Username": "username",
        "Password": "password",
        "Database": "dbname",
        "Schemaname": "dbo",
        "Tablename": "table name",
        "Impersonate": false,
        "AdvancedSettings": "",
        "IsEnableSSL": false,
        "CommandTimeout": 300,
        "IsSshConnection": false,
        "SshServerName": "",
        "SshPort": 0,
        "SshUsername": "",
        "SshPassword": "",
        "ThresHold": true/false,
        "ThresHoldDataLimitValue": 20
      }
    }   

Enabling Threshold:

To enable the threshold property, you need to set the ThresHold property to true and specify a ThresHoldDataLimitValue. Here’s an example of how to set it in your JSON configuration:

{
  "Name": "string",
  "Type": "string",
  "DataSourceId": "string",
  "Description": "string",
  "Connection": {
  "Servername": "localhost",
    "Query": "SELECT * FROM [dbo].[Orders] AS [Orders]",
    "IntegratedSecurity": false,
    "Username": "username",
    "Password": "password",
    "Database": "dbname",
    "Schemaname": "dbo",
    "Tablename": "table name",
    "Impersonate": false,
    "AdvancedSettings": "",
    "IsEnableSSL": false,
    "CommandTimeout": 300,
    "IsSshConnection": false,
    "SshServerName": "",
    "SshPort": 0,
    "SshUsername": "",
    "SshPassword": "",
    "ThresHold": true,
    "ThresHoldDataLimitValue": 20
  }
}

In this example, the threshold is enabled, and the data limit is set to 20. This means that only 20 records will be fetched from the data source.

image.png

image.png

Disabling Threshold:

If you want to disable the threshold and fetch all available data from the data source, set the ThresHold property to false:

{
  "Name": "string",
  "Type": "string",
  "DataSourceId": "string",
  "Description": "string",
  "Connection": {
  "Servername": "localhost",
    "Query": "SELECT * FROM [dbo].[Orders] AS [Orders]",
    "IntegratedSecurity": false,
    "Username": "username",
    "Password": "password",
    "Database": "dbname",
    "Schemaname": "dbo",
    "Tablename": "table name",
    "Impersonate": false,
    "AdvancedSettings": "",
    "IsEnableSSL": false,
    "CommandTimeout": 300,
    "IsSshConnection": false,
    "SshServerName": "",
    "SshPort": 0,
    "SshUsername": "",
    "SshPassword": "",
    "ThresHold": false,
    "ThresHoldDataLimitValue": 20
  }
}

When the ThresHold property is set to false, the ThresHoldDataLimitValue is ignored, and there is no limit to the amount of data fetched.

image.png

The threshold is disabled by default when creating the data source in code view.

Enable/Disable the Threshold Option in UI level:

  • Create the data source.
  • Switch to the code view by enabling the slider option in the tools pane in data design view as shown in the following image.
    image.png
  • Customize the query as you like and enable or disable the threshold to limit the data.

You can also manage the Threshold option in UI level for the data sources created via REST API

Additional References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
GR
Written by Gayathri Ravichandran
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied