Closed w3ich3rt closed 1 year ago
Hey guys,
currently I'm working on a python script, that can manage SCCM via the ConfigMgr WebService. But I kind of stuck while trying to import a computer to the SCCM.
Other requests are successfull:
host = "host" secret = "mylittlepony" url = "https://" + host + "/ConfigMgrWebService/ConfigMgr.asmx" payload="""<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GetCWVersion xmlns="http://www.scconfigmgr.com" /> </soap12:Body> </soap12:Envelope>""" headers = { 'Content-Type': 'application/soap+xml; charset=utf-8' } response = requests.request("POST", url, headers=headers, data=payload, verify = False) print(response.text)
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetCWVersionResponse xmlns="http://www.scconfigmgr.com"> <GetCWVersionResult>1.8.0</GetCWVersionResult> </GetCWVersionResponse> </soap:Body> </soap:Envelope>
But if I try to import a computer with a snippet like this:
# Add Computer to SCCM byMacAddress host = "host" secret = "mylittlepony" url = "https://" + host + "/ConfigMgrWebService/ConfigMgr.asmx" computer = 'Computer' mac = '18-02-74-37-47-6A' payload="""<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <ImportCMComputerByMacAddress xmlns="http://www.scconfigmgr.com"> <secret>{secret}</secret> <computerName>{resource}</computerName> <macAddress>{mac}</macAddress> </ImportCMComputerByMacAddress> </soap12:Body> </soap12:Envelope>""".format(secret=secret, resource=computer, mac=mac) headers = { 'Content-Type': 'application/soap+xml; charset=utf-8' } response = requests.request("POST", url, headers=headers, data=payload, verify = False) print(response,"\n",response.text)
I get only this and no host will be added... what is wrong?
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <ImportCMComputerByMacAddressResponse xmlns="http://www.scconfigmgr.com" /> </soap:Body> </soap:Envelope>
Currently we are using (as you can see in the first code snippets) the version 1.8.0 of the ConfigMgr.
I also tried different formats of the mac-address and hostnames. Help would be appreciated.
Kind regards!!
We solved the issue... it was not a problem with the API call. It was a problem with the permissions.
After setting the right permissions for our request it works!
Hey guys,
currently I'm working on a python script, that can manage SCCM via the ConfigMgr WebService. But I kind of stuck while trying to import a computer to the SCCM.
Other requests are successfull:
But if I try to import a computer with a snippet like this:
I get only this and no host will be added... what is wrong?
Currently we are using (as you can see in the first code snippets) the version 1.8.0 of the ConfigMgr.
I also tried different formats of the mac-address and hostnames. Help would be appreciated.
Kind regards!!