Last active
September 20, 2017 19:53
-
-
Save jdmills-edu/00795693110c156bba622e808191d452 to your computer and use it in GitHub Desktop.
A PowerShell script that changes the status of a Zendesk ticket.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory=$true)][Int32]$ticketID, | |
[Parameter(Mandatory=$true)][ValidateSet('open', 'pending', 'on-hold', 'solved')][String]$ticketStatus | |
) | |
#Zendesk API Connection Headers Referencing System Environmental Variables for username and API token. | |
$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($ZendeskAPI_Username):$($ZendeskAPI_Token)"));} | |
#Zendesk API: Update Ticket | |
$uri = "https://yourdomain.zendesk.com/api/v2/tickets/$ticketID.json" | |
$json = '{ | |
"ticket": { | |
"status": "'+$ticketStatus+'" | |
} | |
}' | |
Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -ContentType "application/json" -Body $json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment