Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
rsuresh
Contributor II
Contributor II

Not able to get export task using export rest api using powershell

Hi Team,

I am trying to export task using export rest api but not able to export task using powershell.

I am trying to with the below command using powershell

$ExportResponse = Invoke-RestMethod -uri "https://qlikmanagerlab.cnppd.lab/attunityenterprisemanager/api/v1/servers/qlikreplicatelab/tasks/CIC..." -Headers $export_headers -Method 'GET' | ConvertTo-JSON | Set-Content "C:\Users\xt28034\Documents\sample1.json"

$outputfile = $ExportResponse | ConvertTo-JSON
Write-Output $outputfile

 =============================================

I am not able to get the output while executing the above command. please help me on this

Labels (1)
1 Solution

Accepted Solutions
Heinvandenheuvel
Specialist III
Specialist III

Well,

  • what's the actual method invoked? it is not visible in the source line.
  • what's the error message? 
  • what did work? Is there even a valid connection/ session/header?
  • Why do you invoke ConvertTo-JSON?

The documentation (Enterprise Manager API Guide) shows the output is "JSON File (stream)", not an object to be converted to json.

I encourage you to use babysteps.  Get the output from the method into a variable. Do a get-member to see what it looks like. Next pipe the variable into a file. See what the file looks like (make sure it is ASCII - the default Encoding for Set-Content.

Personally I prefer the "Enterprise Manager .NET API" as is seems more natural to the Powershell environment to me:  $json = $client.ExportTask("localhost","testtaskname")

$AemServer   = 'localhost'       # change AEM server location as need be
$AemURL      = "https://" + $AemServer + "/attunityenterprisemanager"
$AemUserName = $env:UserDomain + '\' + $env:UserName
$dll = 'C:\Program Files\Attunity\Enterprise Manager\clients\dotnet\AemRestClient.dll'  #  QEM ??
Import-Module $dll        # point to DLL. actual location or copy.
$credential = Get-Credential -Credential $AemUserName
$client = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)
$client                        # Display
if (-not $client) { return }   # Did we get a useable client object ?
$client | Get-Member           # Show all available methods.
$json = $client.ExportTask("localhost","sql_2_sql")
$json | Set-Content x.json

 

View solution in original post

6 Replies
Heinvandenheuvel
Specialist III
Specialist III

Well,

  • what's the actual method invoked? it is not visible in the source line.
  • what's the error message? 
  • what did work? Is there even a valid connection/ session/header?
  • Why do you invoke ConvertTo-JSON?

The documentation (Enterprise Manager API Guide) shows the output is "JSON File (stream)", not an object to be converted to json.

I encourage you to use babysteps.  Get the output from the method into a variable. Do a get-member to see what it looks like. Next pipe the variable into a file. See what the file looks like (make sure it is ASCII - the default Encoding for Set-Content.

Personally I prefer the "Enterprise Manager .NET API" as is seems more natural to the Powershell environment to me:  $json = $client.ExportTask("localhost","testtaskname")

$AemServer   = 'localhost'       # change AEM server location as need be
$AemURL      = "https://" + $AemServer + "/attunityenterprisemanager"
$AemUserName = $env:UserDomain + '\' + $env:UserName
$dll = 'C:\Program Files\Attunity\Enterprise Manager\clients\dotnet\AemRestClient.dll'  #  QEM ??
Import-Module $dll        # point to DLL. actual location or copy.
$credential = Get-Credential -Credential $AemUserName
$client = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)
$client                        # Display
if (-not $client) { return }   # Did we get a useable client object ?
$client | Get-Member           # Show all available methods.
$json = $client.ExportTask("localhost","sql_2_sql")
$json | Set-Content x.json

 

rsuresh
Contributor II
Contributor II
Author

Hi Team,



Please help me with the command to run the export task using powershell.


Heinvandenheuvel
Specialist III
Specialist III

Suresh,  you wrote only: "Please help me with the command to run the export task using powershell."

That's a very dissapointing reply from a professional in the context of the earlier question and answer.

Please up your game!    Specially with respect to the basic skill of good question asking.

A fairly complete answer was given. If you have problems with that, indicate specifics.

Guidance was given on how to you might solve your challenge. Please indicate the efforts you put into that and what the outcome was.

btw, One way to run an export task from command shell or Powershell, on a Replicate server, is to simply use the REPCTL EXPORTREPOSITORY command which is documented in the Replicate Userguide.

Also, What problem are you ultimately trying to solve, what is the purpose of the export? Maybe there are better ways.

Hein.

 

rsuresh
Contributor II
Contributor II
Author

Hi Hein,



Thanks for the quick response.



The issue what I am facing is I am trying to export task using powershell but it is not exporting the task as expected.


Heinvandenheuvel
Specialist III
Specialist III

Unbelievable!  You are still not providing pertinent information to help us help you.

We are not psychic! Share with us EXACTLY what you you expected, EXACTLY what you tried, and EXACTLY what was the result, preferably EXACTLY highlighting what the issue with that was if not very obvious (like and error).

And please re-read the first reply carefully and apply it!

Please go do your homework before asking again.

Regards,

Hein

 

 

Heinvandenheuvel
Specialist III
Specialist III

@rsuresh did you figure it out?

 Inquiring minds would like to know. Perhaps you can share your problem/solution to help others?

Thanks,

Hein