Using the API

Learn how to access data in the Mobile Data Anywhere portal via the Web API

Getting started with the API

Mobile Data Anywhere exposes most of its data through a REST API. This API provides access and basic CRUD operations (create, read, update, delete) for the resources described below. The API supports both XML and JSON formats.

The resources that are exposed via the API include:

  • Devices
  • Projects
  • Sessions
  • Attachments
  • Queued Actions

The API reference documentation can be found at the link below. It describes how to authenticate with the API, and what resources are exposed.

API Reference

There is also a C# .NET implementation of a client library which wraps the API in an easy to use client API. The client API also exposes a COM interface, which allows you to access the library from any COM compatible language including but not limited to the following languages:

  • C# .NET
  • VB .NET
  • Delphi
  • VBA

You can download the .NET Client Library, source code and examples from the Downloads page.

The rest of this tutorial will walk you through a few examples of how to get started accessing the API using the client library in C# and in VBA.

Generating your API Token

Before you can access the API you will need to get access to your API Token which is unique for your username. Once you have your API Token you can use that in combination with your username to get access to the API.

Log into the Mobile Data Anywhere portal and go to your User Profile by pressing the link at the top right of the page. There will be a default API Token created for you in the API Accessibility section. Api user profile

You can also regenerate the API Token by pressing the Edit Tab, then scrolling to the bottom of the page and pressing the Re-Generate Token button. Api regenerate api token

A simple C# example

To get started you will need to download and install the Mobile Data Anywhere API Client Library from the downloads section.

You will also need to download and install Microsoft Visual Studio.

Download and install the Mobile Data Anywhere API Client Library on a Windows PC.

Once installed you will be able to go to the directory C:\Program Files (x86)\Mobile Data Anywhere Client API\Examples\C# and you will find file called SampleClient.csproj. Open the file with Visual Studio.

The C# example is a Console Application that relies on the Courier sample project. The Courier project will need to be uploaded into your Mobile Data Anywhere portal. When you first created your account the Courier project would have been uploaded to your account already. If you have deleted the project there is a copy in the directory C:\Program Files (x86)\Mobile Data Anywhere Client API\Examples\. Upload the project to the Portal, send it to a device, collect a few sessions and send the sessions back to the portal. Once you have the Project and the data in the portal then you must enter your Username and API Token into the source code and run the test application.

Go back to Visual Studio and open the file Program.cs. Enter the Username and API Token in the variables userName and apiSecret. Api c example apikey

Before you run the example application make sure that there is a valid reference to the MobileDataAnywhereAPIClient Library.

To do this expand the References section in the Solution Explorer. If there is an exclamation mark on the MobileDataAnywhereAPIClient reference then you will need to add it. Api c example invalid reference

To add the reference first delete the old one then right click the References folder, select Add References, Browse to the folder C:\Program Files (x86)\Mobile Data Anywhere Client API\ClientAPI and add the file MobileDataAnywhereAPIClient.dll.

Run the application by pressing F5 or the Start button at the top of the page.

A console application will be launched and it will start to download sessions and other data from your account and display it on the screen. The example will demonstrate how to do things like:
  • Connect to the API
  • Get the device count
  • List all devices in your account
  • Check if the Courier project is in your account
  • List all projects in the account
  • Read and display the sessions in the Courier project
  • Download a session and an attachment
  • Create a new session and send it to a device
Now you have connected to the portal and interacted with your account and the sample Courier project using the API. The next step is to modify the example and connect to one of your own projects.

A simple VBA example in Excel

To get started you will need to download and install the Mobile Data Anywhere API Client Library from the downloads section.

Download and install the Mobile Data Anywhere API Client Library on a Windows PC

Once installed you will be able to go to the directory C:\Program Files (x86)\Mobile Data Anywhere Client API\Examples\Excel and you will find the file called SampleClient.xlsm Open that file with Excel.

The example relies on the Courier sample project. The Courier project will need to be uploaded into your Mobile Data Anywhere portal. When you first created your account the Courier project would have been uploaded to your account already. If you have deleted the project there is a copy in the directory C:\Program Files (x86)\Mobile Data Anywhere Client API\Examples\. Upload the project to the portal, send it to your device, collect a few sessions and send the sessions back to the portal. Once you have the Project and the data in the Portal then you can enter your Username and API Token into the sheets in the spreadsheet and run the test application.

Go back to Excel and go to the Devices sheet. Enter the Username and API Token in the cell labelled "Enter username here" and "Enter secret API here". Api excel example apikey

Before you run the example application make sure that there is a valid reference to the MobileDataAnywhereAPIClient library.

To do this press the Developer Tab and the View Code button. This will launch Microsoft Visual Basic. Select the Tools->References menu item. If the MobileDataAnywhereAPIClient is nto available in the list of references then browse to the folder C:\Program Files (x86)\Mobile Data Anywhere Client API\ClientAPI and add the file MobileDataAnywhereAPIClient.dll. Api excel example addreference

To add the reference, first delete the old one then right click the References folder, select Add References, Browse to the folder C:\Program Files (x86)\Mobile Data Anywhere Client API\ClientAPI and add the file MobileDataAnywhereAPIClient.dll.

Go back to the Excel file in the Devices Tab and press the List Devices button.

This will access the API and display all of the Devices in your account. Api excel example list devices

Follow the same steps on the Projects Sheet to list all of the Projects in your account. Api excel example list projects

Follow the same steps on the Sessions Sheet to list all of the Sessions in the Courier Project in your account. Api excel example list sessions

Now you have connected to the portal and listed Devices, Projects and Sessions with your account and the sample Courier project using the API. The next step is to modify the example and connect to one of your own projects.