.NET C# SysAid Api (Basic Ticket Submit with code)

  • 8 April 2014
  • 1 reply

So, after spending all my time doing this from scratch I figured I'd save everyone else a few hours of google/forum searching.
This is the quick way to get a basic C# SysAidApi going to submit Tickets from your own webpage (references at the bottom in case you also wish to load them into your UI).
It's very easy to do however, finding the documentation to do this is a time sink and is what makes this harder than it should be.

First, get your wsdl from the SysAid software (Settings > Integration > SysAid API). If you aren't the admin you'll have to go find your admin and get the wsdl link from them.

After you've done that, using VS 2013 (steps will be similar for older versions), make a new blank C# project that outputs a class library
-do not mark options for web api in the project template window, you want a blank/empty project
-I tried adding the service reference to an existing project but, I ran into issues with my code not being able to find the references/namespace to the API (very odd, let me know if you find the cause)

After you've made the empty project, in Solution Explorer right click the project -> Add -> Service Reference...

Under "Address:", enter your wsdl link and click go.

The service will show up, click the expansion arrow and select the SysaidApiService and give it a namespace (I called mine SysAidApi)
Click OK. Build the project once to generate your .dll and move to your actual project where you are doing ticket loading/submitting.

In your project doing all the work (let us call it "TicketSubmit" for this example), add the .dll from your SysAidApi project as a reference.
Open your web.config in project TicketSubmit and, add this block (found in your SysAidApi web.config) inside the <configuration> tag:
<binding name="SysaidApiServicePortBinding" />
<endpoint address="[your wsdl link]"
binding="basicHttpBinding" bindingConfiguration="SysaidApiServicePortBinding"
contract="SysAidApi.SysaidApiService" name="SysaidApiServicePort" />

This allows your project making the call to the SysAidApi to see the service, save the web.config and go to your C# code behind. If you wish to point your project at a test database just update the <endpoint address=""> to the url for your local test db. (Someone else worked with sysaid to get the test db setup for me so I'm not sure of the details for that)

Add your using statement:
using SysAidApi.SysAidApi //using projectName.ApiNameSpace

Now, the basic code to submit a ticket:

//get the sysaid service
SysaidApiServiceClient service = new SysaidApiServiceClient();

//your login information
string accountId = "SysAidID";
string userName = "user";
string password = "password";

//log into the service
long sessionId = service.login(accountId, userName, password); //your sysaid information to login to the database, if you are only submitting tickets you can use a default user account

//build new ticket
apiServiceRequest ticket = new apiServiceRequest();

//ticket properties
ticket.title = "Title";
ticket.description = "description";

//How to handle custom database fields
apiServiceRequestEntry1 entry1 = new apiServiceRequestEntry1();
entry1.key = "custom_DB_Column_Name";
entry1.value = "value(s)";

//instantiate the customFields Array (it is null by default in the ticket)
apiServiceRequestEntry1[] customFieldsArray = new apiServiceRequestEntry1[1];

//add your created entry's
customFieldsArray[0] = entry1;

//assign the arrow to the customFields property of your apiServiceRequest
ticket.customFields = customFieldsArray;

//save ticket, and notify your user of its success
if (service.save(sessionId, ticket) != null)
showMessage("Your request has been submitted to the Trihydro support Team.", "success");
showMessage("There was an issue saving your request, please contact Trihydro Support.", "error");


I hope this saves someone time in the future.

References for further use:
//full custom load/save integration in VB (far more useful than the API guide, also has the VB source code use as a .zip download)

//Basic C# setup, provides how to load a ticket

1 reply

//How to handle custom database fields
apiServiceRequestEntry1 entry1 = new apiServiceRequestEntry1();
entry1.key = "custom_DB_Column_Name";
entry1.value = "value(s)";

How can you add a second entry key and value?

Regards, Danny