When using AutoTask’s API it’s required to lookup a various amount of picklist values that are used in updating you’re web request. This is a powershell way to pull those picklist values. The first part of the script validates your AT URI, the second part gets the entity data, in this case I was looking for “ticket” related fields.
Edit: Updated to give a more friendly output
# Username and password for Autotask $ATurl = "https://webservices1.autotask.net/atservices/1.5/atws.wsdl" $ATusername = "{AT Username}" $ATpassword = ConvertTo-SecureString "{AT Password}" -AsPlainText -Force $ATcredentials = New-Object System.Management.Automation.PSCredential($ATusername,$ATpassword) $atws = New-WebServiceProxy -URI $ATurl -Credential $ATcredentials $zoneInfo = $atws.getZoneInfo($ATusername) $ATurl = $zoneInfo.URL.Replace(".asmx",".wsdl") $atws = New-WebServiceProxy -URI $ATurl -Credential $ATcredentials $entity= $atws.getFieldInfo("Ticket") foreach ($picklist in $entity) { $picklist | select Name,Label,Description | ft foreach ($values in $picklist.PicklistValues) { $values | select Label,Value,IsActive } } $output= $atws.getThresholdAndUsageInfo() $output.EntityReturnInfoResults.message
When I run this, every line but the last one works. I get this error:
New-WebServiceProxy : Object reference not set to an instance of an object.
At line:1 char:28
+ $atws = New-WebServiceProxy <<<< -URI $zoneInfo.URL -Credential $credentials
+ CategoryInfo : NotSpecified: (:) [New-WebServiceProxy], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewWebServiceProxy
The URL returns properly from the getZoneInfo() call, but the following creation of the web service does not work.
Have you ever run into this issue or have any idea what the issue is?
thanks for catching that, the url being returned by the getZoneInfo() had the wrong extension and wasn’t referencing the .wsdl but the .asmx file which would result in the error you were seeing. I updated the script above to reflect a replace to use the right extension.
Sweet, you the man. Can you offer any explanation why they return the asmx link if you need the wsdl one?
I’m using that command in this example to be universal, that command doesn’t understand what language you’re using to query it, it just returns that URL. I’m using it more to get the zone location (i.e. you might be webservices1.autotask.net where I might be webservices5.autotask.net for the beginning of the URL). This way it works for everyone. I posted this up, but I always hard-code my URL instead of looking it up in the script, why I missed the error on the .asmx.
guys, i need something like this accept it must be for the contacts
Just change this: $entity= $atws.getFieldInfo(“Ticket”)
to this: $entity= $atws.getFieldInfo(“Contact”)
Don’t know if you have noticed, but my colleague published an Autotask Module for PowerShell recently. It uses the SOAP schema to autogenerate PowerShell functions for all possible operations on all entities the API allows, and supports picklists as well.
It still has a few bugs, but has simplified our work with the Autotask tremendously – now most limits are in the actual API – not our ability to use it.
https://klemmestad.com/2018/01/16/finally-an-autotask-powershell-module/
Kristoffer,
This is pretty nice. We’ve created microservice functions now that uses our own code base to make Autotask’s SOAP API more REST friendly for us. I’ll have to take a look at this though.
Thank you this was very helpful to me!