gavsto / AutomateAPI

Powershell Module for the ConnectWise Automate API
GNU General Public License v3.0
84 stars 48 forks source link

Create Invoke-AutomateAPIRestMethod function #36

Closed jasonrush closed 1 year ago

jasonrush commented 5 years ago

Create an Invoke-AutomateAPIRestMethod function, instead of a separate "Set-AutomateAPIGeneric" function.

Example code:

Function Invoke-AutomateAPIRestMethod
{
param(
    $Endpoint,
    $Method,
    $Body)
    $TokenExpiration = [DateTime]::Parse($TokenObject.ExpirationDate)
    if((Get-Date) -gt $TokenExpiration)
    {
        Connect-AutomateAPI
    }
    Invoke-RestMethod -Uri "$($script:baseurl)$Endpoint" -Method $Method -Headers $script:header -Body $Body #-ContentType "application/json" 
}
DarrenWhite99 commented 1 year ago

Marking closed. All calls are handled through the single Invoke-AutomateAPIMaster function.