Simple ARAPI.NET Query Example in C#

Now that you have ARAPI.NET installed let’s take a look at an example using C#. There are a couple of tricks required to get your C# project to compile and run properly.

  • Be sure the ARAPI.NET library is installed correctly and that the directory path has been added to your System PATH environment variable.
  • Set the “Target Platform” to x86 in the Build properties of your Visual Studio project.
  • Add references for both BMC.ARSystem.dll and BMC.arnettoc.dll to your project.
    Project Reference
  • Include the “using BMC.ARSystem;” statement in your code.

In this example I am creating a simple query to find all the users in Remedy that are configured as “Support Staff” and output that list in a CSV format. I have used this to do a periodic audit of our users and remove users that have changed job roles and no longer need “Support Staff” access.

using System;
using System.Collections.Generic;
using BMC.ARSystem;

namespace SupportStaff
  class Program
    static void Main(string[] args)
      string arServerName = "";
      string arUsername = "Demo";
      string arUserPassword = "Password";
      string arAuthentication = "";
      Int32 arServerPort = 51100;

      // Log into the AR Server
      Server arServer = new Server();
      arServer.Login(arServerName, arUsername, arUserPassword, arAuthentication, arServerPort);

      // Create list of fields we want to return from the Form
      EntryListFieldList peopleEntryFieldList = new EntryListFieldList();
      peopleEntryFieldList.AddField(1, 50, ""); // Person ID
      peopleEntryFieldList.AddField(4, 50, ""); // Remedy ID
      peopleEntryFieldList.AddField(1000000025, 50, ""); // Support Staff
      peopleEntryFieldList.AddField(1000006694, 50, ""); // Auth Alias
      peopleEntryFieldList.AddField(1764007102, 50, ""); // Network ID

      // Create the Qualifier string used to query the Form
      string qualifier = @"'1000000025' = 0"; // Support Staff value 0 = 'Yes'

      // Execute the query
      EntryFieldValueList entryListWithFields = arServer.GetListEntryWithFields("CTM:People", qualifier, peopleEntryFieldList, 0, 0);

      //Process the results
      if (entryListWithFields.Count != 0)
        foreach (var entry in entryListWithFields)

I am an experienced IT technologist specializing in optimizing user experiences, providing best-in-class support and developing creative solutions. I script therefore I am. I build tools to improve troubleshooting and gather supporting data.

Tagged with: ,
Posted in ARAPI, Remedy
3 comments on “Simple ARAPI.NET Query Example in C#
  1. Christopher Speed says:

    How do you pass that the qualifier with a parameter? If the value of Yes/No is stored in a variable. I tried string qualifier = @”‘1000000025’ = arYesNo” but doesn’t give me the value for arYesNo.


    • Sean Wheeler says:

      That is a question of C# syntax. The qualifier is just a string so you just need to build the string. So if you have the value of Yes/No stored in the variable arYesNo it might look like this:

      string qualifier = @”‘1000000025’ = ” + arYesNo.ToString();


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

sean on it
Follow Sean on IT on
Blog Stats
  • 65,942 hits
Mike F Robbins

Scripting | Automation | Efficiency

%d bloggers like this: