MileageByState
- This method is associated with the "Mileage By State" Report in AutoGuard and contains Miles Driven per Vehicle per State
-
Returns following information:
- Total Miles Driven for Time/Date Range
- Total Miles Driven for each State for Time/Date Range
- Total Miles Driven for each Day for each State
Use Case
- Use to query mileage each vehicle traveled per day per State
Use an HTTP POST request to obtain your vehicle's Mileage By State:
Request Header
The request header should contain the API Token obtained from the authentication process. Get Access Token.
Header Name | Description |
---|---|
Authorization | API Token obtained from the 1st step's authentication process. |
Request Parameters
The Request should contain the following parameters:
Parameter Name | Description | Value Format | Example |
---|---|---|---|
FromDateTime | Beginning Date/Time for your query* | MM/dd/yyyy hh:mm tt | 08/08/2018 05:00 AM |
ToDateTime | Ending Date/Time for your query* | MM/dd/yyyy hh:mm tt | 08/08/2018 11:00 PM |
Is12HrsFormat |
"True" value for 12-Hour formatting of time; "False"/"Blank" for 24-Hour formatting |
true or false | true |
ShowStateTotalsOnly (Optional) | Filter by showing only State Mileage Totals which excludes mileage driven each day per State. | true or false | true |
VehicleId (Optional) | Filter by a specific VehicleID; "blank" returns all Vehicles | numeric | 825 |
* Date/Time will return all matching events without consideration of Vehicle Time Zone. However, the Event Time returned will include the Time Zone designation.
Create MileageByState Object
Below is the MileageByState request API examples:
var client = new HttpClient();
var values = new Dictionary
{
{ "FromDateTime", "08/08/2018 05:00 AM " },
{ "ToDateTime", "08/08/2018 11:00 PM " },
{ "Is12HrsFormat", "true" },
{ "ShowStateTotalsOnly ", "true" },
{ "VehicleId","845" }
};
client.DefaultRequestHeaders.Add("Authorization","Bearer YOUR_API_TOKEN")
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://secure.autoguardtracking.com/WebApi/api/v2.0/MileageByState", content);
var responseString = await response.Content.ReadAsStringAsync();
//responseString will contain a Credential Object in JSON format
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Authorization","Bearer YOUR_API_TOKEN");
},
type: "POST",
url: "https://secure.autoguardtracking.com/WebApi/api/v2.0/MileageByState",
dataType: "json",
data:{
FromDateTime : "08/08/2018 05:00 AM" ,
ToDateTime: "08/08/2018 11:00 PM",
Is12HrsFormat: true,
ShowStateTotalsOnly : "true",
VehicleId: "845"
},
success: function(data){
//data object will contain the result as a JSON object
}
});
Sample MileageByState Object
A successful request will return the following JSON result:
Test
Test the MileageByState using your AccessToken by entering it below:
Clicking the test button will send a request to the AutoGuard API and display the result below.