Created
September 20, 2017 20:26
-
-
Save jdmills-edu/e8b9272f07e946a73682a6977dce4696 to your computer and use it in GitHub Desktop.
This PowerShell script updates a custom field on a given 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)][Int32]$fieldID, | |
[Parameter(Mandatory=$true)][string]$fieldValue | |
) | |
#Zendesk API Connection Headers Referencing System Environmental Variables for username and API token. | |
$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($env:ZendeskAPI_Username):$($env:ZendeskAPI_Token)"));} | |
#Zendesk API: Update Ticket | |
$uri = "https://yourdomain.zendesk.com/api/v2/tickets/$ticketID.json" | |
$json = '{ | |
"ticket": { | |
"custom_fields": [ | |
{ "'+$fieldID+'": "'+$fieldValue+'" } | |
] | |
} | |
}' | |
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