Here is sample code written in C# to create a Company.

using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
namespace TeamSupport.Api.Consumer
{
  class Program
  {
    static void Main(string[] args)
    {
      // Create a company
      string URI = "https://app.[ServerName].teamsupport.com/api/xml/customers";
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
      string organizationID       = "{Your organization ID}";
      string apiToken             = "{Your API Token}";
      string credentials          = string.Format("{0}:{1}", organizationID, apiToken);
      Byte[] credentialsByteArray = UTF8Encoding.UTF8.GetBytes(credentials);
      string encodedCredentials   = Convert.ToBase64String(credentialsByteArray);
      request.Headers.Add("Authorization", "Basic " + encodedCredentials);
      request.Method      = "POST";
      request.ContentType = "application/xml";
      request.UserAgent   = "your organization name";
      MemoryStream stream = new MemoryStream();
      XmlTextWriter writer = new XmlTextWriter(stream, new UTF8Encoding(false));
      writer.Formatting = Formatting.Indented;
      writer.WriteStartElement("Customer");
      writer.WriteElementString("Name", "Second Company, Inc.");
      writer.WriteElementString("Website", "www.secondcompany.com");
      writer.WriteElementString("Customercustomfield1", "CustomField1Value");
      writer.WriteFullEndElement();
      writer.Flush();
      stream.Position = 0;
      StreamReader reader = new StreamReader(stream);
      string body = reader.ReadToEnd();
      Byte[] bodyByteArray = UTF8Encoding.UTF8.GetBytes(body);
      int offSet = 0;
      int count = bodyByteArray.Length;
      using (Stream requestStream = request.GetRequestStream())
      {
        requestStream.Write(bodyByteArray, offSet, count);
      }
      HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    }
  }
}

Here is sample code written in PHP to create a ticket.

<?php
/* CREATE TICKET */
$orgID='ORGANIZATION_ID';
$apiToken ='Your_API_KEY';
$input_xml="<Ticket>
     <TicketStatusID>28730</TicketStatusID>
     <TicketTypeID>13237</TicketTypeID>
        <TicketTypeName>Support</TicketTypeName>
        <Name>Title goes here</Name>
        <Description>This is the content of the new ticket description.</Description>
        <Status>New</Status>
   </Ticket>";
  $host="https://app.[ServerName].teamsupport.com/api/xml/Tickets";
  $base64str=base64_encode("$orgID:$apiToken");
  $process = curl_init();
  curl_setopt( $process, CURLOPT_URL, $host );
  curl_setopt( $process, CURLOPT_POST, true );
  curl_setopt($process, CURLOPT_HTTPHEADER,array('Content-Type: application/xml', 'Authorization: Basic '.$base64str));
  curl_setopt($process, CURLOPT_TIMEOUT, 30);
  curl_setopt($process, CURLOPT_POSTFIELDS, $input_xml);
  curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
  $return = curl_exec($process);
  $response = curl_getinfo( $process );
  curl_close($process);
  print_r($return);

Click here to learn more about our API.

Need more help with this?
Don’t hesitate to contact us here.

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.