I’m running a simple API call using the code below which requires HaloAPI module;
Connect-HaloAPI -ClientID $Secret:HaloAPI.Username -Tenant 'xxxxxxxx' -URL "https://xxxxxx.haloitsm.com/auth" -ClientSecret $Secret:HaloAPI.GetNetworkCredential().password -Scopes "all" | Out-Null
$Array = @{ticket_id=8547; note="New user created by script"; new_status=30; outcome='API Update'}
New-HaloAction $Array
If I run it as a normal script, it works fine.
If I run it directly in Powershell on the server, it works fine.
If I run it at the very top of a Dashboard, directly under ‘# Put code you’d like to run during dashboard startup here.’ It works fine.
If I try and run it as part of a dashboard flow, it errors. The same dashboard code worked perfectly in Universal v3 as part of a dashboard.
# Put code you'd like to run during dashboard startup here.
# Get menu code from the file below
. .\Dashboards\DashboardComponents\DashboardMenu.ps1
New-UDDashboard -Title 'Test Halo API' -Pages @(
# Create a page using the menu to the right ->
# Reference the page here with Get-UDPage
New-UDPage -Name 'Test Halo API' -id 'TestHaloAPI' -Content {
# Styles
. .\Dashboards\DashboardComponents\DashboardStyles.ps1
# Header
. .\Dashboards\DashboardComponents\DashboardHeader.ps1
# Title
$DashboardTitle = "Test Halo API"
$DashboardDescription = "Test Halo API"
. .\Dashboards\DashboardComponents\DashboardTitle.ps1
Show-UDModal -Persistent -Header {
New-UDElement -tag 'Div' -Content {
New-UDIcon -Icon "Warning"
New-UDTypography "Warning" -Style $ModalHeaderTypographyStyle
}
} -Content {
New-UDHtml "Test Halo API?"
} -Footer {
New-UDButton -Icon (New-UDIcon -Icon 'Check') -Text "Yes" -OnClick {
Show-UDModal -Persistent -Header {
New-UDElement -tag 'Div' -Content {
New-UDIcon -Icon "Spinner" -Spin
New-UDTypography "Working ..." -Style $ModalHeaderTypographyStyle
}
} -Content {
New-UDHtml "Posting to Halo API."
} -Footer {
} -HeaderStyle $ModalHeaderWorkingStyle -ContentStyle $ModalContentStyle -FooterStyle $ModalFooterStyle -MaxWidth 'xs'
Connect-HaloAPI -ClientID $Secret:HaloAPI.Username -Tenant 'xxxxxxx' -URL "https://xxxxxxxx.haloitsm.com/auth" -ClientSecret $Secret:HaloAPI.GetNetworkCredential().password -Scopes "all" | Out-Null
$Array = @{ticket_id=8547; note="New user created by script"; new_status=30; outcome='API Update'}
New-HaloAction $Array
} -Style $ModalGreenButtonStyle -ShowLoading
New-UDButton -Icon (New-UDIcon -Icon 'XMark') -Text "No" -OnClick {
Hide-UDModal
} -Style $ModalRedButtonStyle
} -HeaderStyle $ModalHeaderWarningStyle -ContentStyle $ModalContentStyle -FooterStyle $ModalFooterStyle -MaxWidth 'xs'
# Footer
. .\Dashboards\DashboardComponents\DashboardFooter.ps1
} -LoadNavigation $Navigation
)
Are things handled differently in v4?
Product: PowerShell Universal
Version: 4.2.6