cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1509
Views
10
Helpful
2
Replies

Getting error - PowerShell script to CUCM / AXL API automation

Chidananda S
Level 1
Level 1

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.

error.JPG

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

2 Replies 2

npetrele
Cisco Employee
Cisco Employee

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

 

dstaudt
Cisco Employee
Cisco Employee

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