site logo

Example: Ticket search (C#)


Example: create / update a ticket and a comment  

This script shows how to:

  • connect to your helpdesk API with your access key
  • search tickets
// This codes was contributed by Sean Haddy from www.w3bdev.com.
// Start a new ASP.NET Website or web project (or extend a new project). Right click on References and click "Add Web Reference"
// Here you will paste the service url to your Mojo Helpdesk Portal… which will look something like this: https://yourportal.mojohelpdesk.com/backend/service.wsdl
// Hit >Go and press no to any security warnings you may receive.
// Pay attention to the 'Web reference name' on the right, you will use this to hook up the proxy.
// After successful add, build the project to ensure the web reference is built.

// ASP.NET/C# Codebehind:

Globals:

private const string accessKey = "youraccesskey";

Page_Load or within any event desired:

// replace all instances of com.mojohelpdesk.mojoreference with 'Web reference name' referred to above
com.mojohelpdesk.mojoreference.BackendService proxy = new com.mojohelpdesk.mojoreference.BackendService();

com.mojohelpdesk.mojoreference.TicketSearchParameters searchParams = new mojoHelpDesk.com.mojohelpdesk.mojoreference.TicketSearchParameters();

searchParams.status = "open";
searchParams.created_days = "7";
searchParams.created_days_before_or_after = "after";

try
{
com.mojohelpdesk.jensonusa.TicketListResponse responseData = proxy.FindTickets(accessKey, searchParams)

for (int i = 0; i < responseData.tickets.Length; i++)
{
// this will output some general information to asp:Label named output
output.Text += "id: " + responseData.tickets[i].id + ", title: " + responseData.tickets[i].title + ", status: " +
responseDatckets[i].status + ", created by: " + responseData.tickets[i].created_by.full_name + "<br />";
}


}

catch (Exception err)
{
// error handling here
}