Using with .NET Framework

Notice from Geotab

On September 17, 2022, the current MyAdmin SDK site will be deprecated, and the MyAdmin SDK will be merged with the Geotab SDK site. Please ensure to update your relevant bookmarks as the site will be inaccessible after this date.

Overview

The .NET SDK tools facilitate the integration of MyAdmin with your own .NET software. All communication to MyGeotab services occurs through HTTPS and the data is serialized in JSON format. The provided .NET library automatically handles both serialization and deserialization of JSON into MyAdmin objects.

MyAdminLib.dll

The inclusion of the Geotab.Internal.MyAdmin.APILib package allows you to interact with the API. The accessory conveniently combines the HTTP and JSON API, so you can focus on writing code. The accessory includes tools to assist with serialization and deserialization of JSON, and provides definitions for MyAdmin object classes. A dll file to be used with .NET Framework projects can be found here. After downloading, unzip the .dll file, add a reference to the accessory in your .NET project, then follow the steps below.

Step 1: Initialization & Authentication

The WebServerInvoker class contains methods that facilitate calls to API functions. To access the invoker, include the following line in your code:

using MyAdminApiLib.Geotab.MyAdmin.MyAdminApi.ObjectModel

Then, create an instance of the API invoker in your code:

WebServerInvoker api = new WebServerInvoker(null, 60000) {Url = “https://myadminapi.geotab.com/v2/MyAdminApi.ashx”};

If needed, you may pass an instance of a class that implements the IWebProxy interface as the first parameter. The second parameter takes a timeout in milliseconds. The recommended value for the timeout is 60 seconds. The parameters required by each method are passed using a Dictionary <string, object>. For example, to authenticate with the API, pass a valid username and password to call the Authenticate method using the code below:

Dictionary<string, object> parameters = new Dictionary<string, object> { { "username", "user@geotab.com" }, { "password", "<password>" } };


ApiUser apiUser = api.Invoke("Authenticate", typeof(ApiUser), parameters) as ApiUser;

The Authenticate method authenticates with the MyAdmin API and, if successful, returns an ApiUser object. The ApiUser object contains the SessionId and UserId — used as the API key for all other methods.

Step 2: Making Calls

Once authenticated, you can call other methods by passing the API key, Session ID, and any parameters required by the method.

// apiKey and sessionId were obtained from ApiUser object returned by Authenticate
Dictionary<string, object> parameters = new Dictionary<string, object> { { "apiKey", apiKey }, { "sessionId", sessionId }, { "serialNo", "G63XXXXXXXX8" } };


ApiDeviceInstallResult installResult = api.Invoke("LookupDevice", typeof(ApiDeviceInstallResult), parameters) as ApiDeviceInstallResult;

More Information

For more information, see .NET Framework examples.