Quantcast
Channel: THWACK: Popular Discussions - Web Help Desk
Viewing all articles
Browse latest Browse all 5301

Adding Tech to WHD Ticket Using REST API Powershell

$
0
0

Afternoon all,

 

So I've got a script set that will update ticket notes and either close or not close said ticket using the REST API with Powershell. However, I'm stuck on how to get it to assign the ticket to a specific Tech and I've been bashing my head on my desk wondering what I'm missing. I know I need to add in another Invoke RestMethod to assign the Tech but I can't seem to find that in the REST API documentation. I know that never gets updated and it's not really supported, so I'm casting out a wide net to see if anyone else has had any success with this one. See below my example code for reference, any help would be greatly appreciated, would really simplify my workload for me. Thanks.

 

Param(

#Get Inputs

[string]$apikey = "ENTER API KEY",

[Parameter(mandatory=$true)]

[string]$ticketNumber,

[Parameter(mandatory=$true)]

[string]$ticketNotes,

[Parameter(mandatory=$true)]

[validateset("Y","N","y","n")]

[string]$closeYorN

)

 

#Get Ticket Details

$ticketDetails = Invoke-RestMethod -Uri "HELP DESK URL/WebObjects/Helpdesk.woa/ra/Tickets/$($ticketNumber)?apiKey=$($apikey)" -Method GET

$problemtypeid=$ticketDetails.problemtype.id

$detaildisplayName=$ticketDetails.problemtype.detailDisplayName

 

#Prompt to close ticket (boolean)

if($closeYorN -eq "Y")

{

$closeTicket = "3"

$ticketTech = Read-Host "Enter tech name to close ticket"

$techID = Read-Host "Enter tech ID number"

}

else

{

$closeTicket = "1"

}

 

#Write ticket details to JSON

$json=@"

{

  "problemtype": {

    "id": "$problemtypeid",

    "type": "RequestType",

    "detailDisplayName": "$detaildisplayName"

  },

  "noteText": "$ticketNotes",

  "jobticket": {

    "type": "JobTicket",

    "id": "$ticketNumber"

  },

  "statustype": {

    "type": "StatusType",

    "id": "$closeTicket"

  }

  "clientTech": {

    "id": $techID

    "type": "Tech",

    "displayName": "$ticketTech

}

"@

 

#Update Ticket Notes

Invoke-RestMethod -Uri "HELP DESK URL/helpdesk/WebObjects/Helpdesk.woa/ra/TechNotes?apiKey=$($apikey)" -Method POST -Body $json -ContentType "application/json"

 

#Close Ticket

Invoke-RestMethod -Uri "HELP DESK URL/WebObjects/Helpdesk.woa/ra/Tickets/$($ticketNumber)?apiKey=$($apikey)" -Method PUT -Body $json -ContentType "application/json"


Viewing all articles
Browse latest Browse all 5301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>