Welcome to Forums Sign in | Join | Help | Forums
in Search


How to Access API using C#

Last post 01-11-2010 12:43 PM by David Zeidman. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-17-2009 1:08 PM

    • Dennis Pulido
    • Not Ranked
    • Posts 1
    • Organization: American Academy of Dermatology

    How to Access API using C#

    I am new user to the RE APIs.  I added the Blackbaud.PIA.RE7.BBREAPI reference.

    What are the other settings needed to access the APIs in my C# app?  Any advice would be greatful.

     Thanks.

  • 04-18-2009 5:02 AM In reply to

    • David Zeidman
    • Top 25 Contributor
    • User Since: 2002
    • Posts 326
    • Organization: Zeidman Development
    • Products:  Blackbaud Direct Marketing, Blackbaud Enterprise CRM, The Information Edge, The Raiser's Edge

    Re: How to Access API using C#

     I don't think that there are many more settings as such. If you want to create a plug-in then you will need to implement the IBBPlugin interface and create a COM visible assembly. If you want to create an application the you will need to use the REAPI object in order to connect to the API and log in to RE. Once you have done these things you are able to use the API object model however you wish.

    Take a look at my blog which has a lot of tips and undocumented information about developing using the API. It is mainly in VB.NET but hopefully should still be understandable to somebody developing in C#.

    David

    David Zeidman
    Zeidman Development
    http://www.zeidman.info

    Check out my RE API blog
    http://www.re-decoded.com
  • 01-11-2010 12:32 PM In reply to

    • Paul Ward
    • Not Ranked
    • Posts 8
    • Organization: CCR Data Limited

    Re: How to Access API using C#

    Erm actually no it's much simpler than that ...

     in your "%RE Install folder%\tlb\" there is a file called "BBREAPI7.tlb" open up a vs command prompt window and navigate to the path i believe the default is something like "C:\Program Files\Blackbaud\The Raisers Edge 7\Tlb".

     Next run "tlbimp.exe" detailed here http://msdn.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx to generate yourself a .NET wrapper.

     Take the generated assembly and copy it to a new project folder under bin (within Visual Studio).

    Reference it.

    add "using AssemblyName" to the top of the class.

    now you should be able to use everything in there which includes the API.

     ....

     For example ...

     

    1. open vs cmd prompt
    2. cd C:\Program Files\Blackbaud\The Raisers Edge 7\Tlb
    3. tlbimp BBREAPI7.tlb /out:REAPI.dll
    4. copy REAPI.dll to new project created in VS
    5. reference REAPI.dll
    6. add "using REAPI"
    7. Create method which contains below code to test ...
    api = new REAPIClass();

    MethodInfo mi = typeof(REAPIClass).GetMethod("Init");

    mi.Invoke(api, new Object[] { "your serial number for RE", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value });

     

    This when called should produce the RE login dialog.

    Some things to be aware of ...

    In order for the login dialog to appear the call to this code must be made within the context of a valid window handle which means you need to ensure that you either make the call in a windows app which has a fully constructed and initialised window object or some other component like IE which can pass on it's own handling context.

     This means you can't make this call in the context of a command prompt application unless you fill in the Missing.Value params with actual values, the actual values are user login details and the API run mode.

    This call works perfectly for me, tried and tested, my "plugin" project is a complex "fuzzy matching wizard" which finds duplicates in the RE database based on further analysis of the RE field values.

    C# and RE are a little bit of an odd combination though, REAPI does not act how you expect it to and the wrapper assembly you generate with tlbimp shows just how different the two systems are.

    .NET if I do say so myself "shows up the REAPI" with it's nice-ness :) ... unless you like VB A LOT !!!

     

  • 01-11-2010 12:43 PM In reply to

    • David Zeidman
    • Top 25 Contributor
    • User Since: 2002
    • Posts 326
    • Organization: Zeidman Development
    • Products:  Blackbaud Direct Marketing, Blackbaud Enterprise CRM, The Information Edge, The Raiser's Edge

    Re: How to Access API using C#

     Unless I am mistaken the init method of the REAPIClass can only be called if your organisation have an unlocked API module. This is fine if you are working with the sample database but otherwise you need to have the module unlocked.

    There really is no reason to go through the steps of referening the BBREAPI dll when the primary interop assembly is already available to you.

    David

    David Zeidman
    Zeidman Development
    http://www.zeidman.info

    Check out my RE API blog
    http://www.re-decoded.com
Page 1 of 1 (4 items)