8 Replies Latest reply on May 19, 2017 8:56 AM by maslicko

    API integration with WHD

    ben.ricardo

      Hi All,

      We've been working through integrating the Solar Winds Web Helpdesk with our in-house Job management/Accounting software and I thought I'd share some results.

      We are using the powershell invoke-restmethod commandlet to query the API interface, but as a big disclaimer I am no expert and have a fair bit of help from the solarwinds team!

      The main reason for posting is that I was very surprised at how little information on integration with this product there was on the web. So for what it's worth here it is.

       

      For those looking, you will need the API manual: http://www.solarwinds.com/documentation/webhelpdesk/docs/whd_api_12.1.0/web%20help%20desk%20api.html

       

      We needed to search for tickets that had a blank custom field so we new which tickets had not yet been synced with our JM/A system.

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?&qualifier=(customFields.stringValue %3D null)&apiKey=keygeneratedundertechaccount" > D:\tickets\NewJobs.txt

       

      Then strip the ticket number out so we could get then query the ticket details. (sorry this became a table when I copied the line into this window...)

      It also strips the leading spaces and outputs each tickets details into a file which is called the ticket number

      select-string -pattern 'id            :' newjobs.txt | foreach {$_.tostring().Split(':')[4].trimstart()} | foreach {Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets/$_/?&apiKey=keygeneratedundertechaccount" > details\$_}

       

      We also wanted to be able to update the ticket custom field with the new job number from our system (you can see the ticket number I was experimenting with was 115 and the json file containing the new field value is called test.json)

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets/115?&apiKey=keygeneratedundertechaccount" -InFile test.json -Method Put


      Contents of the test.json file looks like this (custom field ID is 13, Job number to be inserted E12345)

      {"customFields": [ {"definitionId": 13, "restValue": "E12345"}]}

       

      It's still a work in progress, as I mentioned I'm no expert. The next thing I have to do is work out how to query to show tickets that have been updated since last time I queried the Helpdesk system... so if anyone wants to chime in please do!

       

      Other information I found useful along the way:

       

      To produce a list of customers locations

       

      Command:

        Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Locations?&apiKey=keygeneratedundertechaccount" >Locations-customersites.txt


      To produce a list of status types

       

      Command:

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/StatusTypes?&apiKey=keygeneratedundertechaccount" >Statustypes.txt

       

      To get a list of priority types

       

      Command:

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/PriorityTypes?&apiKey=keygeneratedundertechaccount" >prioritytypes.txt

       

      To request a list of request types

      Command:

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/RequestTypes?&apiKey=keygeneratedundertechaccount" >requesttypes.txt

       

      Get a list of Techs and their IDs

       

      Command:

      Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Techs?&apiKey=keygeneratedundertechaccount" >techs.txt

       

      Ben