Knee Deep in CVent API, Logging in

Image representing Cvent as depicted in CrunchBase
Image via CrunchBase

I have to admit, I’ve never worked with an API before, ok I’ve pulled an image from flickr or the twitter feed on the side bar with API but someone else showed me how to do that. For work I had to write vb.net code to work with CVent’s API. So over the next few post, I’ll be adding code that may help others (Since I could find any for the API newbie!), I will also admit that this isn’t the prettiest or even the most logical code but it works for how we’re doing things and will give you a beginning point to work with.
There are many spots in the code that the API uses arrays and as you’ll see I’ve created my loops to add only a single element into the array. I know, I know but when you’re on a tight schedule and you’re just figuring out the API, if something works, you go with it.. and if you use my code and actually change it to work correctly, please send me your examples so I can share with everyone. (richard(@)curbob.com).

Lets start at the beginning.. adding the API to VisualStudio
You have to have an API account with Cvent to even access the API, so untill all contracts are signed, don’t even try. I thought for a day I was doing something wrong.. nope, no access.
To connect VS2005/2008 to CVent API, right click the project in solution explorer and choose “Add Web Reference”. The URL is https://api.cvent.com/soap/V200611.asmx?WSDL. After adding this URL I was bombarded with 4 popup boxes asking about letting this secure page show, click yes on all of them and also unblock the activeX content. Then Click Add Reference.

Private _ws As New com.cvent.api.V200611()

Lets login into CVent API

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Login("account Number", "UserName", "Password") = True Then
            Label1.Text = "Login worked"
        Else
            Label1.Text = "Login failed"
        End If
    End Sub
Public Function Login(ByVal Acct As [String], ByVal userName As [String], ByVal pwd As [String]) As [Boolean]

        Dim loginResult As com.cvent.api.LoginResult = _ws.Login(Acct, userName, pwd)
        _ws.CventSessionHeaderValue = New com.cvent.api.CventSessionHeader()
        _ws.CventSessionHeaderValue.CventSessionValue = loginResult.CventSessionHeader

        Return (loginResult.LoginSuccess)
    End Function

Technorati Tags: , ,

     

8 Comments to “Knee Deep in CVent API, Logging in”

  1. Juan 21 October 2011 at 11:10 pm #

    Hello,

    I’m investigating a potential integration with the CVent API. I’m having a hard time finding any official documentation. Is it publicly available?

    Cheers,
    Juan

  2. Richard Curry 13 December 2011 at 10:28 am #

    I’ve asked Cvent if there is a link for me to download a current version of the documentation. I’ll report back when I hear from them

  3. nickspiers 11 January 2012 at 8:45 pm #

    I know the article is old, but it looks like the comments are pretty current.
    I found this documentation.
    http://www.mediaworksinc.net/uploads/resources/1-api_version_v200611_phaseii_05042007.pdf

  4. Amit 13 February 2012 at 7:27 am #

    I have also started working on cvent and after looooot of searching i found the link for api = https://api.cvent.com/soap/V200611.ASMX

  5. Richard Curry 14 February 2012 at 2:13 pm #

    That will give you the basic info on the API but since 2007 alot has been added to the API

  6. CventAPIUser 28 March 2016 at 2:40 pm #

    Hi,

    I’m completely new to using both visual studio and the cvent api so trying to get this to work might be a stretch. I’m basically looking to login to the API, and make a relatively simple call to pull any new registrations to the event into our SQL server database. So far I’ve created a new Visual Studio project in VS 2015 and added the web reference. Could you provide a little more information on how I add this login code into the project? When I click add reference I get a long list of options and I’m not sure how to add the code above. And is this vb code for use in a vb project?

    Thanks for your help in advance, seems like you have a lot of experience with the API!

    Best
    Andrew

  7. Richard Curry 28 March 2016 at 3:25 pm #

    Andrew, you should be able to copy the above code into your VS 2015 in your page load. As per loading the web reference, this post may help http://tek-works.com/adding-a-web-reference-in-visual-studio-2008/

    Also make sure your company has paid for the API and Cvent has your company & server IP address and they’ve given you a username and password. They lock down the API pretty good.

    When I started with Cvent API, I was in the same boat, I had no idea where to even begin, that’s why I’ve documented some of it. But still alot of my code isn’t the greatest, I need to get better at sending the data to Cvent in a large Array instead of little updates, many times, but I don’t have the time to go in and fix my work, it works for now.

    in the above example, make sure to replace the “accountnumber, username and password” with what Cvent sends you.

  8. CventAPIUser 29 March 2016 at 3:21 pm #

    Thanks Richard, we’ve definitely set up access and I think I’ve even logged in before I just can’t recreate how I did it!

    The tutorial for the web reference worked perfectly, that’s all in there. I still haven’t worked out where to put the code though. Where do I access the page load in VS? And does all the code go in the same place? And I’ve created this as a Visual Basic Windows Forms application, is that right?

    Thanks!
    Andrew


Leave a Reply