Hi Sinha,
I used the acquire_wfa_cache command and tried it in our workflow it always failed with the following error
The remote server returned an error: (401) Unauthorized.
Then later changed the rest uri to use the server name instead of localhost the error went away.
Here is my changed code.
param (
[parameter(Mandatory=$true, HelpMessage="Data Source Name")]
[string]$DSName,
[parameter(Mandatory=$true, HelpMessage="Schema")]
[string]$Schema,
[parameter(Mandatory=$true, HelpMessage="WFA server hostname")]
[string]$Wfahostname,
[parameter(Mandatory=$false, HelpMessage="TCP Port")]
[int]$TCPPort,
[parameter(Mandatory=$false, HelpMessage="Use Secure")]
[boolean]$UseSSL=$false
)
$path = "C:\passwd"
$password = Get-Content $path | ConvertTo-SecureString -key (1..16)
$username = "wfauser"
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
if ( $TCPPort )
{
if (!$UseSSL)
{
$add = "http://{$Wfahostname}:$TCPPort/rest/data_sources/$DSName/$Schema/jobs"
}
else
{
$add = "https://{$Wfahostname}:$TCPPort/rest/data_sources/$DSName/$Schema/jobs"
}
}
else
{
if (!$UseSSL)
{
$add = "http://$Wfahostname/rest/data_sources/$DSName/$Schema/jobs"
}
else
{
$add = "https://$Wfahostname/rest/data_sources/$DSName/$Schema/jobs"
}
}
Get-WFALogger -Info -message $("Calling REST with uri: "+ $add)
$dsResult = Invoke-RestMethod -Uri $add -Method Post -Credential $cred -ContentType "application/xml"
$jobId = $dsResult.acquisitionJob.jobId
Get-WFALogger -Info -message $("Job ID: "+ $jobId)
$add = $add + "/$jobId"
$jobStatus = ''
while ( $jobStatus -ne 'COMPLETED' )
{
$status = Invoke-RestMethod -Uri $add -Method Get -Credential $cred -ContentType "application/xml"
$jobStatus = $status.acquisitionJob.jobStatus.status
if($jobStatus -eq "FAILED")
{
throw ("Failed to acquire Datasource : " + $status.acquisitionJob.jobStatus.errorMessage)
}
else
{
Get-WFALogger -Info -message $("Acquisition Job Status: "+ $jobStatus)
Start-Sleep -Seconds 2
}
}
Any reason why local host would fail ?
Regards
Adai