Recent searches
No recent searches
Zendesk API and PowerShell
Posted Feb 15, 2024
I'd like to pull in some data from Zendesk using PowerShell. I am using the example found. Unfortunately, there was an issue "error: cannot authenticate you" The token and email address are correct.
Is there a resolution to this issue or another way to pull the data?
0
7
7 comments
Jakub
Hello Tyler Duncan
I would appreciate it if you could share your API call so I can see if I can give you any tips what might be causing this error to be returned. Thanks!
0
Tyler Duncan
Hi Jakub
I am using the example I have found on reddit. The token and email address are correct. The permissions are setup correctly. The API cannot be connected.
0
Jakub
Here's the corrected code:
$Username = "username@domain.com/token"
$Token = "kasjdfkljasdfkjds"
$Base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($Username):$($Token)"))
$params = @{
Uri = "https://{subdomain}.zendesk.com/api/v2/requests.json"
Method = 'Get'
Headers = @{
Authorization = "Basic $Base64AuthInfo"
}
}
$result = Invoke-RestMethod @params
$Tickets = $result.tickets
$Tickets
Make sure to replace {subdomain} with your actual Zendesk subdomain, and ensure that $Username and $Token contain the correct values for your Zendesk account.
Also, note that $result is being used to store the result of Invoke-RestMethod, but in your original code, you didn't assign the result to the $result variable. I've added that assignment in the corrected code above.
0
Tyler Duncan
Jakub
Thank you. There must be an issue on where I am running it. I am using PowerShell Universal to run the API, and unfortunately it will not authenticate my token and email.
0
Jakub
0
Tyler Duncan
Jakub
Thank you. I think there may have been an issue with the token I was using. Is there are difference in using the a token created in App Integration verses using the token that is created via Api (.../oauth/tokens/)?
0
Jakub
0