Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this wrapper to find subitems? #50

Closed
me1299 opened this issue Jan 5, 2023 · 2 comments
Closed

How to use this wrapper to find subitems? #50

me1299 opened this issue Jan 5, 2023 · 2 comments

Comments

@me1299
Copy link

me1299 commented Jan 5, 2023

I'm trying to query EntityInformation fields. I know the API call should be:
/ATServicesRest/V1.0/Tickets/entityInformation/fields

But using Get-AutotaskAPIResource I have to use a resource. There is no resource EntityInformationFields or anything like that. How do I query this? I cannot find any supporting documentation in the readme.

Edit: they are called picklist values.

@me1299
Copy link
Author

me1299 commented Jan 6, 2023

I just wrote some code without the this wrapper to fetch them. I must say the API is easy to query using Invoke-WebRequest.

$BaseURL = "https://webservices19.autotask.net/ATServicesRest/V1.0"

$ApiIntegrationCode = 'XXX'
$UserName           = 'XXX'
$Secret             = 'XXX'

$Headers = @{
    'ApiIntegrationCode' = $ApiIntegrationCode
    'UserName'           = $UserName
    'Secret'             = $Secret
}

$Uri = "$BaseURL/Tickets/entityInformation/fields"

$Picklists = ((Invoke-WebRequest -Uri $Uri -Method "GET" -ContentType 'application/json' -Headers $Headers -UseBasicParsing).Content | ConvertFrom-Json).Fields

#Monitoring Alert ID opzoeken
$IssueId = (($Picklists | Where-Object {$_.Name -Eq "issueType"}).picklistValues | Where-Object {$_.Label -Eq "Monitoring Alert"}).value

#SUBS van Monitoring Alert opzoeken
$SubIssueIds = ($Picklists | Where-Object {$_.Name -Eq "subIssueType"}).picklistValues | Where-Object {$_.parentValue -Eq $IssueId}

@phill-holbrook
Copy link
Contributor

phill-holbrook commented Jan 11, 2023

Hi @me1299

The New-AutotaskBody cmdlet can be used to query picklists. For example:

$Body = New-AutotaskBody -Resource Tickets
$Body

This cmdlet is dual purpose in that it also builds an object you can use to create or update existing resources. Unfortunately there seems to be a bug when querying picklist values in the Contracts entity, for which I'll open a separate issue.

EDIT:

The bug I found has already been opened: #49 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants