Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
RajneeshSharma
Contributor III
Contributor III

Python equivalent of Curl PUT command

Hi

I used this command to change the properties of qlik replicate server

curl -i -k -v -X PUT --header "EnterpriseManager.APISessionID: AsC5-21nyeyvwF_zobRL4Q" https://abcd/attunityenterprisemanager/api/v1/servers/abcd/def -T "myrepsrv1.json"

Above is working fine. This is my myrepsrv1.json file contents. 

{"$type": "AemReplicateServer", "name": "abcd", "description": "test", "host": "somehost", "port": "3552", "username": "admin", "password": "{{}}", "verify_server_certificate": false, "monitored": true}

How can I write the python equivalent of above command. I tried below but its not working

response_put = requests.put(
'https://abcd/attunityenterprisemanager/api/v1/servers/abcd/def - T myrepsrv1.json',
headers=headers,
verify=False
)

I get below error

{'Cache-Control': 'no-cache, no-store', 'Content-Length': '0', 'Server': 'Microsoft-HTTPAPI/2.0', 'Application-Status': '500', 'Application-Message': "SYS-E-UNRECREQ, Unrecognized request pattern 'PUT: /v1/servers/abcd/def%20-%20T%20myrepsrv1.json'.", 'Application-Detailed-Message': 'SYS,UNRECOGNIZED_REQUEST_PATTERN,PUT,/v1/servers/abcd/def%20-%20T%20myrepsrv1.json', 'Date': 'Thu, 04 Apr 2024 09:29:54 GMT'}

Clearly it didnt like the url pattern but then how to write the correct code/pattern. Thanks

Labels (1)
1 Solution

Accepted Solutions
Heinvandenheuvel
Specialist III
Specialist III

Well, how to make HTTP request from Python is a Python usage problem so best ask/read a Python forum, Clearly you cannot use CURL parameter passing, 

However, if you want to drive AEM from a python script, I would use the well documented AEM Python interface/library and specifically the put_server call.

Mind you, I have a hard time understanding your focus (in this, and prior topics) on server definitions. Those I personally would always do manually and 'test', but I suppose if you have to automate a large scale roll-out or are building a recovery script then using the API can help automate. Or maybe it is just the first step you opted to try?  In that case I suggest getserverlist and gettasklist as first API calls to try, using existing servers/tasks definitions.

Documentation snippet below,

Hein.

Enterprise Manager API Guide Qlik Enterprise Manager

November 2023 - Last updated: February 12, 2024

 

4   Enterprise Manager Python API
4.7 put_server
Adds a new Replicate/Compose Server or updates the server definition (Connection Properties) if the specified
server already exists. ...
Required User Role: See Required Enterprise Manager permissions (page 257).
Syntax: def put_server( self, payload, server)

 

 

View solution in original post

1 Reply
Heinvandenheuvel
Specialist III
Specialist III

Well, how to make HTTP request from Python is a Python usage problem so best ask/read a Python forum, Clearly you cannot use CURL parameter passing, 

However, if you want to drive AEM from a python script, I would use the well documented AEM Python interface/library and specifically the put_server call.

Mind you, I have a hard time understanding your focus (in this, and prior topics) on server definitions. Those I personally would always do manually and 'test', but I suppose if you have to automate a large scale roll-out or are building a recovery script then using the API can help automate. Or maybe it is just the first step you opted to try?  In that case I suggest getserverlist and gettasklist as first API calls to try, using existing servers/tasks definitions.

Documentation snippet below,

Hein.

Enterprise Manager API Guide Qlik Enterprise Manager

November 2023 - Last updated: February 12, 2024

 

4   Enterprise Manager Python API
4.7 put_server
Adds a new Replicate/Compose Server or updates the server definition (Connection Properties) if the specified
server already exists. ...
Required User Role: See Required Enterprise Manager permissions (page 257).
Syntax: def put_server( self, payload, server)