AssetTrack Upload API

Overview

AssetTrack provides an API allowing data to be sent into AssetTrack through the AssetTrack Queue. It enables programmatic feeding of data to AssetTrack from other systems such as auto-discovery, active directory or others, which is then validated and published to the configured database target the same as if collected via an AssetTrack Mobile device or web form.

Licensing

The AssetTrack Upload API is licensed as a separate module which can be installed on top of an existing AssetTrack Server.  Contact sales@amitracks.com for pricing information.

Usage

First, define an AssetTrack Upload form that contains the data fields expected by the upload.  Upload forms can be configured and protected via permissions the same as any AssetTrack form.

Next, write a program that performs the following steps:

  1. Authenticates against the API, receiving a cookie value that will be used to authenticate the upload calls to the API.
  2. Creates a formatted JSON object that represents the Upload form data and posts the it to the correct API end point.

Methods

Please note the following that is true for calling AssetTrack API end points:

  • The paths specified assume a default installation of the API, which creates a virtual directory, /AssetTrackApi. If you have customized the installation to a different root directory, change the endpoint paths accordingly.
  • When posting JSON arguments to an API end point, the following should be true:
    • The JSON should be added to the BODY of the HTTP request.
    • Add the header, "Content-Type: application/json"

Login

Endpoint/AssetTrackApi/api/login
HTTP method

POST

JSON argument
{
"Password": string
"UserName": string
}
Response

Successful Auth:

HTTP Status200
Cookie (in response headers).ASPXAUTH
JSON (in response body)
{
 "Status": "Authenticated",
"Cookie": {
  "Name": ".ASPXAUTH",
  "Path": "/",
 "Expires": "2015-06-17T23:41:19.3019067+00:00",
 "Value": "[cookie value]"
}
}

 

Unsuccessful Auth:

HTTP Status401
JSON (in response body)
{
"Status":"InvalidCredentials",
"Message":"The user name and/or password provided is incorrect."
}

 

Upload forms data submission

 

Endpoint/AssetTrackApi/api/TaskData/DelimitedData
HTTP method

POST

JSON argument
{
// A client-defined unique ID for the submittal.
// This gets used by the AssetTrack server to create a System Log entry for the data
// submission to help uniquely identify the upload request in case there are errors
// encountered while processing of the data.
"SubmittalId" : "UploadFormPosting_2015-06-17T17:05:00.021Z",

// The ID of the task for which you are uploading data
// 1) You can use the form display name, but this could change out from under you by an
// AssetTrack administrator during form design (customizable)
// 2) You can use the form unique GUID, found by viewing the Upload Form page's frame URL
// when you are on in the AssetTrack web application.
// 3) You can save a bit of data transmission overhead by base-64 encoding the GUID
// e.g. Convert.ToBase64String(new Guid(txtOutput.Text).ToByteArray());
"TaskId" : "6f091c81-ce8d-478c-99b8-633a195d4a40",
 // An array of string values specifying the column headers contained in the
// data that is being submitted. These values should correspond to the
// columns specified in the Upload form's file template.
"Columns" : ["Asset Tag", "Status"],
 // An array of string arrays representing the row data. One string array for each row,
// with the values aligning in position with the columns specified above.
"Rows" : [
["A00000001", "Received"],
["A00000002", "Received"]
]
}
Response

Successful:

HTTP Status200
JSON (in response body)
{
// The submittal id you provided in the original request
"SubmittalId": "UploadFormPosting_2015-06-17T17:05:00.021Z"
}

Sample App

A sample Windows application, written in C#, is provided here showing how to submit data to AssetTrack using the upload API.