site logo

Example: Ticket update (Ruby)


Example: create / update a ticket and a comment  

This script shows how to:

  • connect to your helpdesk API with your access key
  • update a ticket with a specific id

 

#!/usr/bin/ruby
########################################
# $Id: update-ticket.rb,v 1.1 2008/07/28 15:31:25 d Exp $
#
# This is an example how to use the Mojo Helpdesk API
# Language: ruby
#
# This script shows how to:
# - connect to your helpdesk API with your access key
# - update a ticket.
#
# You will need to adjust the URL and MYID values:
#
# URL - Base URL to your helpdesk.
#
# MYID - Your access key, as displayed on your "profile" page
#
########################################
# Feel free to use this code and modify to fit your needs.
# More information visit www.mojohelpdesk.com
########################################
require 'soap/wsdlDriver'
require 'open-uri'

########################################
# Your helpdesk URL
# URL = "http://supportxyz.mojohelpdeskcom
# MYID = "8b1459cfcb367d72419e2642e56fa3b72bc5c2a0"
#
# Replace the info below with your own:
########################################
########################################
URL = "http://myhelpdesk.mojohelpdesk.com"
MYID = "1c5f8839c504defffab67b258844741f10cf7a48"
########################################
begin
drv = SOAP::WSDLDriverFactory.new("#{URL}/backend/service.wsdl").create_rpc_driver
rescue
printf "Fatal error: Could not connect to server.wsdl or an error occured (%s). Check your URL and try again.\n", $!; exit(-1)
end

printf ">>> WSDL found.\n"

#
# Updating ticket id = 992
#
t = {}
t['title'] = " MODIFIED TITLE "
puts ">>> Updating ticket"
res = drv.UpdateTicket("#{MYID}", 992, t)
if res['successful'] == true
printf ">>> Ticket update successful\n"
puts res.inspect
else
printf ">>> Ticket update failed\n"
printf ">>> Error: %s\n", res['error_message']
end

exit(0)