Skip to main content

I've tried passing a credentials object or even passing the API key in the URL, but every request is returning require_login:true.


Invoke-RestMethod -Method Put -Uri "https://[redacted API key]:password@mydomain.freshdesk.com/helpdesk/tickets/12345678.json" -Body (ConvertTo-Json $body) -Header @{"Content-Type"="application/json"}


Any ideas?



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




That's great! Thanks!