Hi Team,
https://help.dataminer.services/WebServices/#t=SLC_UM_DataMinerWebServices%2FWS_Methods_v0%2FConnect.htm
Can anyone please help me to understand why the following python code to make an API call to dataminer does not work
import requests
headers1 = {
"host": "localhost",
"Content-Type": "application/x-www-form-urlencoded"
}
data1 = {
"Login": "XXX",
"Password": "XXX",
"connection" : "10df979a-6bbd-412b-9182-66a38f0ec4eb",
"dmaID":"41303",
}
r = requests.post("http://10.207.7.224/api/v0/Connection", headers = headers1, data=data1)
print(r.text)
I would recommend to use JSON with the v1 interface:
import requests
headers1 = {
"Accept": "*/*",
"Content-type": "application/json"
}data1 = {
"host": "localhost",
"login": "XXX",
"password": "XXX",
"clientAppName": "My App",
"clientAppVersion": "",
"clientComputerName": ""
}r = requests.post("http://10.207.7.224/API/v1/Json.asmx/ConnectApp", data=data1, headers = headers1)
Note:
- the v0 interface is deprecated.
- without using HTTPS, the password will be send unencrypted.
I can’t spot the mistake here, might be something related to the Python syntax, I’m not that experienced with Python. Maybe the comma after “AskForConfirmation”: False shouldn’t be there?
Also the Folder should not contain the full path with the Skyline DataMiner directory, it’s a virtual path that you can see in the Automation module in Cube.
I tried doing the same in Postman, with the same properties defined as in your data, and it works.
With DataMiner version 9.6.0, it is also necessary to specify the properties Dummies, Parameters and MemoryFiles, they can be empty arrays.
Thanks Wim / Miguel,
With a couple of adjustments this is looking more positive….
REQUEST
import requests
headers1 = {
“Host”: “localhost”,
“Accept”: “*/*”,
“Content-Type”: “application/json”
}
data1 = {
“host” : “localhost”,
“login”: “XXX,
“password”: “XXX”,
“clientAppName”: “drl-python”,
“clientAppVersion”: “”,
“clientComputerName”: “”
}
r = requests.post(“http://10.207.7.224/API/v1/json.asmx/ConnectApp”, headers = headers1, json=data1)
print(r.text)
RESPONSE:
{“d”:”22d9db83-852f-XXX-XXX-XXX”}
I am not trying the https://help.dataminer.services/WebServices/#t=SLC_UM_DataMinerWebServicesWS_Methods_v1_methodspt1ExecuteAutomationScript.htm
import requests
headers1 = {
“Host”: “localhost”,
“Accept”: “*/*”,
“Content-Type”: “application/json”
}
data1 = {
“connection” : “22d9db83-852f-XXX-XXX-XXX”,
“script” : {
“Name” : “Email test”,
“Description” : “Daniel Test”,
“Folder”: “C:Skyline DataMinerScripts”,
“Settings” : {
“RequireInteractive” : False,
“HasFindInteractiveClient” : False
}
},
“scriptOptions” : {
“WaitForScript” : False,
“CheckSets” : False,
“LockElements” : False,
“ForceLockElements” : False,
“WaitWhenLocked”: False,
“IsInUse” : False,
“AskForConfirmation” : False,
}
}
r = requests.post(“http://10.207.7.224/API/v1/json.asmx/ExecuteAutomationScript”, headers = headers1, json=data1)
print(r.text)
RESPONSE:
{“Message”:”Error trapped: Object reference not set to an instance of an object.”,”StackTrace”:” at Skyline.DataMiner.Web.Common.v1.AutomationModule.ExecuteAutomationScript(String connection, DMAAutomationScript script, DMAAutomationScriptOptions scriptOptions)rn at Skyline.DataMiner.Web.v1.Json.ExecuteAutomationScript(String connection, DMAAutomationScript script, DMAAutomationScriptOptions scriptOptions)”,”ExceptionType”:”Skyline.DataMiner.Web.Common.WebApiException”}
>>>
I have not included all the variables in the script – are they all necessary and related to this issue?
Many thanks