Forum Discussion

villasenorbritt's avatar
villasenorbritt
Resolver I
3 years ago

API Request Blocked by Keyblocker

I am getting an error when trying to push data into Bi from SQL via Powershell. It says that ""The request was blocked by Keyblocker". I tried limiting my query to under 10,000 rows with no luck. Here is my code:

 

(PowerShell)

$dataSource = '******' #Server Name
$userName = '****** ' #SQL User Name
$password = '*********' #SQL User Password
$database = '*******' #Database Name

$connectionString ="Server=$dataSource;Database=$database;trusted_connection=false; user id =$userName;Password=$password;Integrated Security=False"
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()

$query = '  
  SELECT [data],[datetime], [id], [source_id] FROM [dbo].[vwResawLine2FPM] 
  '
$command = $connection.CreateCommand()
$command.CommandText = $query
$dataset = $command.ExecuteReader()
#paste the endpoint URL which you have inside Power BI
$endpoint = "ENDPOINT"
#push data to Power BI 
while ($dataset.Read()) {
    $payload = @{
                "data" =$dataset['data']
                "datetime" =$dataset['datetime']
                "source_id" =$dataset['source_id']
		"id" =$dataset['id']
    } 
    Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))
}
$connection.Close();
$connection.Dispose();

 

 

I am hoping someone here has an indication of the issue. Basically, there is not much online explaining what this issue could be outside of the info found in the normal documentation, and I believe I have abided by the API limitations. 

2 Replies