4 Replies Latest reply on May 4, 2018 8:57 AM by comtcjm

    Adding Tech to WHD Ticket Using REST API Powershell

    rcklewis

      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"

        • Re: Adding Tech to WHD Ticket Using REST API Powershell
          justin.gray@weldre4.k12.co.us

          As far as I know, the only option for assignment is 'assignToCreatingTech', which of course has limited functionality.

           

          Presumably if you have your Locations, Tech Groups, etc. sorted out, tickets should go to the correct Tech based on the specific request type, no?

           

          FWIW, I've gotten ok support from Solarwinds on the API, so it might be worth an ask to see if they ideas.

           

          Sorry, not much help...

          • Re: Adding Tech to WHD Ticket Using REST API Powershell
            fluffy midnight

            If you have auto-assignment enabled, then raising a ticket via the API to the corresponding request type will auto-assign the tech as expected.

             

            As Justin has mentioned, you can assign the ticket tech creator using the 'assignToCreatingTech', however this would only be for initial use and is very limited.

             

            To my knowledge there is no way to specify the assigned technician once the ticket is submitted, you would need to have help desk configuration to assign it accordingly depending on different setup.

             

             

            With all this being said, you should be able to create a Ticket Custom Field that has an Action Rule to auto-assign to the specific technician you want (depending on the criteria of the custom field, I'd recommend single-choice), and then have the API work with that Custom Field to assign the tech you are wanting, and close the ticket as you normally would.

             

            Also, here's the API Guide for anyone that needs it (The API has not changed much since 12.2.0, therefore a new version was never published since): Web Help Desk REST API Guide

            1 of 1 people found this helpful
              • Re: Adding Tech to WHD Ticket Using REST API Powershell
                rcklewis

                With auto assignment it would make things easier to assign the request type to a specific tech, only issue from our group is that there are multiple people in my team's "tech group" and auto assign is only set for our group as a whole by our WHD admin (hard set on this function by the higher ups, will not change). As for 'assigntoCreatingTech' unfortunately that would not work either as people outside of our department have access to WHD to submit tickets, which would ultimately assign the ticket to the end user that submitted the request, if I'm understanding the use of that function. We also have others in our department that will create tickets and assign them to our tech group later (file transfers for example). I've put it on the back burner for now, not really a pressing matter at this point, was just trying to simplify my daily process of going through and updating tickets and closing them. I've been able to successfully update the ticket status and the ticket notes using the above script, outside of contacting Solarwinds Support there's not much else I can do for this one to figure out how to assign the ticket to a specific tech by their ID once the notes have been updated and the ticket status has been changed.

                 

                 

                Appreciate the insight guys!

                  • Re: Adding Tech to WHD Ticket Using REST API Powershell
                    comtcjm

                    You could trigger the assignment using an action rule(s):

                    You could have a hidden ticket custom field (e.g. Assign Tech) which you set via the API, then have actions rules (1 per tech you need to assign) to monitor the custom field to see if it is set to a certain tech name. Then assign the ticket to that tech in that action rule, remembering to clear your custom field after in the next part of the action rule.

                     

                    Another method is to use a custom field again similar to above, that has a action rule that moves the ticket to a Request Type that has only 1 tech with auto assign, then moves the ticket back to the original Request Type, which should maintain the assignment. You would need a structure of request types, 1 per tech. Messy option...

                     

                    regards

                    Chris.