How To View Odometer/Engine Hours Adjustment Using An API Call

Applies To

  • MyGeotab
  • SDK
  • Odometer
  • Odometer Adjustment
  • Engine Hours Adjustment

Procedure

  1. Navigate to the API runner https://geotab.github.io/sdk/software/api/runner.html
  2. Login to the corresponding server
  3. Run the following API call to get Odometer/Engine Hours adjustment for all Vehicles with in the database
    var date = new Date(),
    deviceCache = [],
    calls = [],
    statusCache = [];
    date = date.toISOString();

    var grabDevices = async function(date, deviceCache, calls) {
    api.call("Get", {"typeName": "Device",
    "search": {
    "fromDate": date
    }
    }, async function(devices) {
    var no = 1;
    deviceCache = devices;
    for (var device in deviceCache) {
    calls.push([
    "Get",
    {
    "typeName": "StatusData",
    "search": {
    "diagnosticSearch": {
    "id": "DiagnosticEngineHoursAdjustmentId"
    },
    "deviceSearch": {
    "id": deviceCache[device].id
    },
    "fromDate": "2018-08-08T00:00:00.000Z"
    }
    }
    ])

    }
    statusCache = statusCache.conct(await sendRequests(calls))
    })
    }

    var sendRequests = function(calls) {
    return new Promise(resolve => {
    api.multiCall(calls, function(success) {
    console.log(success);
    }, function(fail) {
    console.log(fail)
    });
    })
    }

    grabDevices(date, deviceCache, calls);
  • Modify the 'disgnostic Search' Id to ""id": "DiagnosticOdometerId" to get the Odometer data
  • Modify the 'fromDate' to get the Data for a specific date

To run the API call for a specific Vehicle in the database use the following code:

api.call("Get", {"typeName": "StatusData",
"search": {
"diagnosticSearch": {
"id": "DiagnosticEngineHoursAdjustmentId"
},
"deviceSearch": {
"id": "b1213"
}
 }
}, function(result) {
  console.log(result);
})
  • Modify the "id": "b1213" to the specific vehicle Id in the database
  • Modify the 'diagnostic Search' Id to ""id": "DiagnosticOdometerId" for searching the Odometer data
  • Modify the 'diagnostic Search' Id to ""id": "DiagnosticOdometerAdjustmentId" for searching the Odometer Adjustment data