API integration with WHD

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

Parents
  • Hi Ben,

    I'm just getting started with the API's, and wanted to know if you were able to create tickets?

  • Hi rford,

    Sorry for the delay responding - I haven't been back to this thread for a while. Do you know if I can subscribe to this thread so I know if someone has asked a question?

    Yes I most certainly have created tickets through the API. You have to use a JSON file and POST it.

    Example command:

    Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets?&apiKey=xdgsgshjfgjfgfgjfgjfgjfjfgjfgjfgjfgjfgjfgjfgjfgjfgjfgjfjfgjfgjfgjfgjfj8fRwM87" -InFile newticket.json -Method Post

    Example contents of JSON file:

    { "reportDateUtc": "2015-1-14T15:45:16Z", "room": "", "emailClient": false, "emailTech": true, "emailTechGroupLevel": false, "emailGroupManager": false, "emailCc": false, "ccAddressesForTech": "", "emailBcc": false, "bccAddresses": "", "subject": "Phone Support", "detail": "WANTED TO SPEAK TO YOU SORRY DIDNT GET WHAT ABOUT -TOMORROW MORNING IS FINE", "assignToCreatingTech": false, "problemtype": { "type": "ProblemType", "id": 7 }, "sendEmail": false, "location": { "type": "Location", "id": 51 }, "clientTech": { "type": "Tech", "id": 2 }, "customField_13": "E123545", "statustype": { "type": "StatusType", "id": 1 }, "prioritytype": { "type": "PriorityType", "id": 2 }, "assets": "" }

    Hope this helps

    Ben

  • Hi Ben,

    Thanks for the reply. I was able to resolve. We had some custom fields that were mandatory.

  • Hi Ben,

    I could not create the ticket. My GET request are working fine but by post requests are not working and the error is "The remote server returned an error (404) not found." Pls help me. can u share some template code if you can.

  • Hi Kevin,

    The template we use is as posted above (it's a copy paste out of our powershell script)

    The only advice I would have for a 404 is watch your upper and lower case letters in the URL as the system is case sensitive!

    Also use something like Notepad++ with the JSON plugin to build and check your file.

    Sorry I can't really offer a direct answer.

    Perhaps you could paste your current API call? Obviously change any sensitive information in it and I can test it out here.

    Cheers

    Ben

  • Hi,

    I have issue with creating ticket as well, but with different error. "Invoke-RestMethod : When no qualifier is provided, must specify a list type (list=mine|group|flagged|recent)." Do you have a idea what I have wrong?

    /Vlad

  • Hi Vlad...I know this is really old but I am getting this same error. Seems like it's a GET error when I am POSTing...

    Did you resolve this and how?

  • Nevermind...the answer is POST/PUT only work with HTTPS. GET will work with either.

Reply Children
No Data