01-21-2022 02:50 AM
I am trying to build a script using Cisco AXL API and PowerShell.
When i try to run the below command i am getting error.
Invoke-RestMethod -Method Post -Uri "https://$cucmServer`:8443/axl/" -Headers @{'Content-Type'='text/xml';'SOAPAction'='CUCM:DB ver=' + $version} -Body $body -Credential $cred
CUCM version - 11.5
PowerShell version - 5.1.19041.1320
any guidance would be very helpful
01-21-2022 07:22 AM
I suspect you're not using powershell for SOAP correctly. It looks like you're trying to use REST to perform the SOAP operation. Here are a couple pages that explain how to use Powershell for SOAP you might find useful:
https://jpearson.blog/2019/04/09/calling-soap-services-from-powershell/
https://codingbee.net/powershell/powershell-web-services-wsdl-and-soap
01-21-2022 10:11 AM
From the error message, it seems that AXL is not seeing the Authorization header credentials, or perhaps they are the incorrect ones. After double checking the username/password are correct, another issue I've seen is some HTTP libraries will not (by default) proactively send the Authorization header but rather wait for a 404 and then re-send the request including credentials. Usually there is an option/setting that allows you to force sending credentials on the first try.
FWIW, this is a PS sample that worked as of CUCM v10.5 (Windows 7):
[System.Net.ServicePointManager]::Expect100Continue = $false $os = Get-WmiObject win32_operatingsystem $body = @' <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.5"> <soapenv:Header/> <soapenv:Body> <ns:doLdapSync sequence="1"> <name>ADFS</name> <sync>true</sync> </ns:doLdapSync> </soapenv:Body> </soapenv:Envelope> '@ $pwd = ConvertTo-SecureString "ciscopsdt" -AsPlainText -Force $cred = New-Object Management.Automation.PSCredential ('Administrator', $pwd) $Result = Invoke-RestMethod -Method Post ` -ContentType "text/xml" -Body $body ` -Credential $cred ` -Uri https://ds-ucm105.cisco.com:8443/axl/ $Result.xml
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide