Developer DocumentationLegacy APISOAP APISample Code
Note

Cvent’s SOAP API is being sunset. See REST API.

The sample C# code illustrates common use cases of the Cvent Web Service API.

Examples are provided for the following scenarios:

  • Logging In
  • Searching for Events
  • Retrieving Event Details
  • Retrieving All Survey Responses Updated Today
  • Setting Up Custom Identity Authentication

Logging In

Use the Login method to retrieve a valid client session and begin to use the Cvent API.

//Private Cvent Web Service class variable
private com.cvent.api.V200611 _ws = new com.cvent.api.V200611();

// Log in with provided credentials
// acctNum – Cvent provided API Account Number
// username – Cvent provided API User Name
// pwd – Cvent provided API password
private Boolean login(String acctNum, String userName, String pwd) {

  //login to cvent web service
  com.cvent.api.LoginResult loginResult = _ws.Login(acctNum, userName, pwd);

  //assign login object to session
  _ws.CventSessionHeaderValue = new com.cvent.api.CventSessionHeader();
  _ws.CventSessionHeaderValue.CventSessionValue = loginResult.CventSessionHeader;

  //return success or fail
  if (loginResult.LoginSuccess) {
    Console.WriteLine(“-- > Login successful”);
  } else {
    Console.Write(“-- > Login failed”);
  }
  return (loginResult.LoginSuccess);
}

Searching for Events

Use the Search method to search for events by event title.

//Private Cvent Web Service class variable
private com.cvent.api.V200611 _ws = new com.cvent.api.V200611();

//Search for events by event title
//eventTitle – Event Title to search for
//string[] – Array of EventIds that match the search criteria public string[] GetEventIdsByTitle(String eventTitle)
{

  //Array of EventIds string[] ids;

  //Create Cvent search object
  com.cvent.api.CvSearch search = new com.cvent.api.CvSearch();

  //Create Cvent search filter object array
  //Create a one-row array of Filter objects
  //Create larger array if searching on multiple fields/filters search.Filter = new com.cvent.api.Filter[1]; search.Filter[0] = new com.cvent.api.Filter();

  //Search by Event Title field and provided search criteria //EventTitle is a “searchable” attribute of the Event object //any searchable attribute can be added as a search filter search.Filter[0].Field = “EventTitle”;

  search.Filter[0].Value = fieldVal;

  //Search for all Event Titles that “start with” provided criteria search.Filter[0].Operator = com.cvent.api.CvSearchOperatorType.Startswith;

  //Specify if the search filters should be used to build an “And” or “Or” search search.SearchType = com.cvent.api.CvSearchType.AndSearch;

  //Perform search for event ids that match the search criteria
  //Note: Use same technique to search for other Cvent objects including //Contacts, Invitees, Registrations, Surveys, etc
  ids = _ws.Search(com.cvent.api.CvObjectType.Event, search);

  //Return string array of event ids

  return (ids);
}

Retrieving Event Details

Traverse an array of Event IDs and use the Retrieve method to analyze or display event details.

//Private Cvent Web Service class variable
private com.cvent.api.V200611 _ws = new com.cvent.api.V200611();

//Display event details by event id //ids – String array of event ids
void DisplayEventsByIds(string[] ids) {

  //Declare an array of CvObjects for later use com.cvent.api.CvObject[] objects;

  if (ids != null && ids.Length > 0) {

    //Retrieve applicable objects corresponding to array of ids //Use same technique to retrieve other Cvent objects, //including Contacts, Invitees, Registrations, Surveys, etc objects = _ws.Retrieve(com.cvent.api.CvObjectType.Event, ids);

    Console.WriteLine(“\nThere are“ + ids.Length + “EVENT records returned from your search.”);

    //Traverse event objects for (int i = 0; i < objects.Length; i++)

    {
      //Cast the retrieved CvObjects to Event objects com.cvent.api.Event evt = (com.cvent.api.Event)objects[i];

      //Print and/or analyze Event Details System.Console.WriteLine(“\n No: “ + i); System.Console.WriteLine(“Event Title: “ + evt.EventTitle); System.Console.WriteLine(“ Start Date: “ +evt.EventStartDate); System.Console.WriteLine(“ End Date: “ + evt.EventEndDate); System.Console.WriteLine(“ Status: “ + evt.EventStatus);

    }
  }

}

Retrieving All Survey Responses Updated Today

Use the GetUpdated method to retrieve all survey responses updated since this morning.

//Private Cvent Web Service class variable
private com.cvent.api.V200611 _ws = new com.cvent.api.V200611();

// Log in with provided credentials
// acctNum – Cvent provided API Account Number
// username – Cvent provided API User Name
// pwd – Cvent provided API password
private Boolean login(String acctNum, String userName, String pwd) {

  //login to cvent web service
  com.cvent.api.LoginResult loginResult = _ws.Login(acctNum, userName, pwd);

  //assign login object to session
  _ws.CventSessionHeaderValue = new com.cvent.api.CventSessionHeader();
  _ws.CventSessionHeaderValue.CventSessionValue = loginResult.CventSessionHeader;

  //return success or fail
  if (loginResult.LoginSuccess) {
    Console.WriteLine(“-- > Login successful”);
  } else {
    Console.Write(“-- > Login failed”);
  }
  return (loginResult.LoginSuccess);
}
Last updated on