Module/RestHelper/RestHelper.ps1
function Get-BasicAuthHeader { param ( [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$userName, [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$PATToken ) $Text = ("{0}:{1}" -f $userName, $PATToken) $Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text) $EncodedText = [Convert]::ToBase64String($Bytes) $Header = @{ "authorization" = "Basic $EncodedText" } return($Header) } function Get-APIAuthHeader { param ( [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$APIKey ) $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("apiKey", $APIKey) return($headers) } |