I am trying to a refresh on a single table in Azure Analysis services using PowerShell and Automation Runbook.
I am passing a bearer token to the header body but while testing it I am getting below error.
Response status code does not indicate success: 415 (Unsupported Media Type)
<#param
(
[Parameter (Mandatory = $false)]
[object] $WebhookData,
[Parameter (Mandatory = $false)]
[String] $DatabaseName,
[Parameter (Mandatory = $false)]
[String] $AnalysisServer,
[Parameter (Mandatory = $false)]
[String] $RefreshType
)#>
$AnalysisServer = "centralus.asazure.windows.net/servers/shipbobanalysisserver01/models"
$DatabaseName = "POC Shipbob TabularModel/refreshes"
$userName = $Credential.UserName
$securePassword = $Credential.Password
$password = $Credential.GetNetworkCredential().Password
$tenantId = ".........................................."
$requestAccessTokenUri = "https://login.microsoftonline.com/$tenantId/oauth2/token"
$resource = 'https://centralus.asazure.windows.net/'
$pass = "..................................."
$requestBody = "grant_type=client_credentials&client_id=$userName&client_secret=$pass&resource=$resource"
$token = Invoke-RestMethod -Method Post -Uri $requestAccessTokenUri -Body $requestBody -ContentType 'application/x-www-form-urlencoded'
#Write-Output $token
$header=@{
"ContentType"="application/json"
"Authorization"="Bearer $($token.access_token)"
"Accept"="application/json"}
$baseUrl = "https://"+$AnalysisServer+"/"+$DatabaseName
$body =
'{
"Type": "Full",
"CommitMode": "transactional",
"MaxParallelism": 2,
"RetryCount": 2,
"Objects": [
{
"table": "Hist_ShipbobLive_dbo_FulfillmentCenterType",
"partition": "Partition"
}
]
}'
Invoke-WebRequest -Uri $baseUrl -Body $body -Headers $header -Method Post -ContentType "aapplication/json"
Can someone please help in debugging this code.
I have tried to get the details of the error by using -Errorvariable RespErr and -SkipHTTPErrorCheck but found no luck.