I have also tried the following with the same results:
$KeyEncode = [System.Text.Encoding]::UTF8.GetBytes("$FDApiKey,$FDApiKey")
$KeyConvert = [System.Convert]::ToBase64String($KeyEncode)
$FDAuthHeader = "Basic " + $KeyConvert
$FDHeaders = @{"Authorization" = $FDAuthHeader}
$testFD = Invoke-RestMethod -Uri $testEndpoint -ContentType application/json -Method GET -Headers $FDHeaders
And all I get is: @{require_login=True}
May have to dig into this with Fiddler, I wish there was an easier way to troubleshoot though.
So I got this to work. Invoke-Restmethod must add something that the Freshdesk api can't handle. Alternatively, you can use the Invoke-WebRequest cmdlet instead. See sample below:
$pair = "$($FDApiKey):$($FDApiKey)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$FDHeaders = @{ Authorization = $basicAuthValue }
$FDBaseEndpoint = "https://domain.freshdesk.com/"
$FDContactData = Invoke-WebRequest -uri $FDBaseEndpoint -Headers $FDHeaders -Method GET -ContentType application/json | ConvertFrom-Json