Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
cferdig_Trek
Contributor
Contributor

API reference

Looking for documentation for API access with the Replication product. I would like to stop and start tasks outside of Qlik via command line or powershell.

Labels (1)
1 Solution

Accepted Solutions
Pedro_Lopez
Support
Support

Hi,

 

Thanks for reaching out. Unfortunately currently there are no APIs available for the Replicate product itself, you would have to use Qlik Enterprise Manager's API to control and manage Replicate tasks, find more info here:

 

https://help.qlik.com/en-US/enterprise-manager/November2022/Content/EnterpriseManager/EnterpriseMana...

 

Hope this helps,

 

Regards,

Pedro

View solution in original post

7 Replies
Pedro_Lopez
Support
Support

Hi,

 

Thanks for reaching out. Unfortunately currently there are no APIs available for the Replicate product itself, you would have to use Qlik Enterprise Manager's API to control and manage Replicate tasks, find more info here:

 

https://help.qlik.com/en-US/enterprise-manager/November2022/Content/EnterpriseManager/EnterpriseMana...

 

Hope this helps,

 

Regards,

Pedro

Heinvandenheuvel
Specialist II
Specialist II

Correction to @Pedro_Lopez 's reply: " there are no SUPPORTED APIs available s available for the Replicate product itself".

However, there always was, still is, and by my estimation always will be, the REPCTL commandline tool.

This toon is DOCUMENTED and only supported for the IMPORT and EXPORT of tasks and a couple more. See the Replicate Userguide "7 Defining and managing tasks" section "To export a task using the command line:". Or just 'find' REPCTL in the userguide.

Now after setting default to the bin directory, or adding the bin directory to you path try: 

  •  repctl -d <data_folder> help option=1

You'll see dozens of potential commands (which do not all work), but you need EXECUTE and STOPTASK which do work today and 99.99% sure tomorrow. Other commands to evaluate: GETTASKLIST and GETTASKSTATUS.

Carefully study the output from

  • repctl -d <data_folder> execute ?  
  • repctl -d <data_folder> stoptask ? 

Usage example

  • repctl -d <data_folder> connect; execute <your_task_name>  operation=3 flags=0

[edit:  Thanks for the reminder @Michael_Litz  - You need a 'connect;' on the command line to communicate (connect to) the actual running replicate service. Without the connect instruction the REPCTL command  uses static data. Statis data is fine for 'help' and 'export' but not to control task]

As per @Pedro_Lopez  the 'best', and only supported, way to control Replicate Tasks is through the Enterprise Manager API.  That's documented in the "Enterprise Manager API Guide" with options for cURL, .NET (my favorite for Powershell use)  and Python.Good luck,

Hein

 

 

Michael_Litz
Support
Support

The following are examples of how to run ( stoptask | gettaskstatus | execute )

These commands are typically used in a batch script to shutdown a replicate task, check its status, resume the task in CDC mode

NOTE: need to run the command line as administrator, the repctl is under the ~\replicate\bin directory.

Replicate command line - running the commands:

Using a task named ORA_2_SQL - NOTE: the task name is case sensitive

C:\Program Files\Attunity\Replicate\bin>repctl connect; stoptask task=ORA_2_SQL; disconnect

C:\Program Files\Attunity\Replicate\bin>repctl connect; gettaskstatus task=ORA_2_SQL; disconnect

C:\Program Files\Attunity\Replicate\bin>repctl connect; execute task=ORA_2_SQL operation=02 flags=00; disconnect

********************************************************************************************************************

Replicate Command Line - Help for a command

NOTE: Commands are case sensitive when refering to the tasks:

For help on a command once in the replcate command line type the command followed by a ?

Two examples below for stoptask and execute:

!!! Get help on Stop Task !!!

C:\Program Files\Attunity\Replicate\bin>repctl
Enter a command or quit
stoptask ?
command stoptask:
request arguments:

task:required string

response arguments:
status:required int32
message:optional string
[stoptask command] Succeeded


!!! Get help on execute task !!!

Enter a command or quit
Execute ?
command Execute:
request arguments:

task:required string
operation:required enum, valid values:
01 - EXECUTE_OPERATIONS_LOAD
02 - EXECUTE_OPERATIONS_CDC
03 - EXECUTE_OPERATIONS_BOTH

flags:optional enum, valid values:
00 - RESUME
01 - FRESH
02 - METADATA_ONLY
03 - FRESH_METADATA_ONLY

cdcposition:optional string


response arguments:
status:required int32
message:optional string
[Execute command] Succeeded
Enter a command or quit

cferdig_Trek
Contributor
Contributor
Author

We are using powershell. A little different than using the repctl it appears. I am the middle man on this assisting a developer. Here is the script. I think we might just be missing something to get a valid response back. Like I said the script works but we get a 500 response even though the task is stopping and starting.

Heinvandenheuvel
Specialist II
Specialist II

>> We are using powershell.

Great, then you can use the Curl API for the Enterprise manager, as well as REPCTL

>> A little different than using the repctl it appears.

Yes, te Curl is much better m, more powerful, supported and better error messages WHICH ARE BARELY CONVEYED. REPCTL is a completely different, simpler, approach and works well from Powershell also.

>> I am the middle man on this assisting a developer.

Get out of the middle. You are not really helping! Let that developer step up and provide pertinent information like WHICH LINE is reporting 500 status, and whether a simple variation on the script can successfully be used find the task and its's status.

>> Here is the script. 

No it is not. It is a near useless picture of a script. If you, or that developer, had provided a TEXT document instead someone could potentially have  tried it and helped you better with that.

Anyway - that HTTP 500 message can have a myriad of underlying reasons depending on the call. So please indicate the actually command use returning the 500, and the  "Enterprise Manager Code" that came with that.

The picture below shows the 3 anticipated 500 responses for STOPTASK as documented in EM API guide @Pedro_Lopez  kindly pointed out.

As you see, It may well be an informational, safely ignored, message such as 'stopped already' as the action supposedly had worked.

Maybe it means 'action initiated but not completed'. The script may use that to request the status in a loop to check whether the action fully completed, or chose to just 'trust' it and move on.

hope this helps,

Hein

Heinvandenheuvel_0-1674769828863.png

 

 

cferdig_Trek
Contributor
Contributor
Author

I respect your response. Advice understood and I will have the developer create their own support ticket for assistance as it appears it would be more appropriate. Thank you.

Heinvandenheuvel
Specialist II
Specialist II

And I respect your feedback, but why not have development reach out here directly. This is NOT a product issue but a product usage issue. Support will surely help explain.

Back in 'the good old days' we'd be send to a couple days training before attempting something like this. Now we are expected to make do with a user guide, forums like these and Google.

Cheers,

Hein.