Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Aug 8, 2023 8:38:46 AM
Aug 8, 2023 8:38:46 AM
This article provides an example on how to use the Qlik Enterprise Manager Python API to start a task from timestamp. The example runs a task by cdcposition using Python API.
This customization is provided as is. Qlik Support cannot provide continued support for the solution. For assistance, reach out to Professional Services.
"""
@author: Vinay Vitta
"""
import json, glob, os, sys, base64, requests, re, time, urllib3
from datetime import datetime
from datetime import timedelta
from calendar import monthrange
from enum import Enum
from copy import copy
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Don't want to print out warnings
RepServer='79' #change Replicate Server name
RepTask='mysql2file' #change for task name
api_base_url = "https://snsql2014a/attunityenterprisemanager/api/v1/" #change for QEM server
auth_string = "Basic c25zcWwyMDE0YVxhZG1pbmlzdHJhdG9yOmhheWV6aXJh" # Change for base64 hash user password ,, make sure to keep the Basic
login_headers = {}
login_headers["Authorization"] = auth_string
print(login_headers)
session = requests.Session()
response = session.get(url=api_base_url + 'login', headers=login_headers, verify=False)
# print(response.json())
if response.status_code == 200:
session_id = response.headers['EnterpriseManager.APISessionID']
api_session_header = {}
api_session_header["EnterpriseManager.APISessionID"] = session_id
session.headers.update(api_session_header)
urlResumeTime='servers/' + RepServer + '/tasks/' + RepTask + '?action=run&option=RESUME_PROCESSING_FROM_TIMESTAMP'
print(api_base_url + urlResumeTime)
data = {"cdcposition": "2023-07-14T01:01:01"} # change for the CDCposition
resumeTimeResponse = session.post(url=api_base_url + urlResumeTime, headers=login_headers, json=data, verify=False)
print(resumeTimeResponse.headers)
Example from the log file of the task executing from timestamp:
00008888: 2023-07-17T16:57:34 [TASK_MANAGER ]I: Task 'mysql2file' running CDC only in fresh start mode, starting from log position: 'timestamp:2023-07-14T01:01:01' (UTC). (replicationtask.c:1770)
00008888: 2023-07-17T16:57:34 [TASK_MANAGER ]I: Feature flags for process are: (ar_feature_flags.c:232)
I have tried to get the session Id with the same code I am getting following error:
"raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='', port=4799): Max retries exceeded with url: /attunityenterprisemanager/api/v1/login (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1122)')))
Process finished with exit code 1"
Hello @shrikantdhumal
Looking up the error message, it looks like it is often caused by either using the wrong port number or using HTTPS where HTTP is expected or the other way around.
If this hint does not help, please post your issue in our Enterprise Manager forum.
All the best,
Sonja