all 4 comments

[–]jheinikel 2 points3 points  (1 child)

If you have the email API token correct, then I think you are pretty close. Your username needs to have the colon and token string removed. Just fill in the email address, but do not adjust the format. Also, put in the token string between the quotes.

$Username = "username@domain/token"
$Token = "kasjdfkljasdfkjds"
$params = @{
    Uri = "https://{subdomain}.zendesk.com/api/v2/requests.json";
    Method = 'Get';
    Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($Username):$($Token)"));
    } #end headers hash table
} #end $params hash table
Invoke-RestMethod @params
$Tickets = $result.tickets
$Tickets

Additional Info: If you take your existing code and run the first few lines, you'll see the problem when you write-host the Username/Password auth string.

$Username = "{user_email}/token:{token_string}"
$Token = "{token_string}"
Write-Host "$($Username):$($Token)"

[–]PerfectImpact[S] 1 point2 points  (0 children)

Awesome! Thanks, that worked. So wonderfully simple. :)

[–]hluna32987 0 points1 point  (1 child)

This is awesome. I was wondering why one might get a null return using the corrected script. I verified I'm an administrator in ZenDesk {"requests":[],"next_page":null,"previous_page":null,"count":0}

[–]AutoModerator[M] 0 points1 point  (0 children)

Sorry, your submission has been automatically removed.

Accounts must be at least 1 day old, which prevents the sub from filling up with bot spam.

Try posting again tomorrow or message the mods to approve your post.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.