Get Device Audit History

Description

For a specified device, returns information about changes that occurred within a given time period as measured from today's date. You can request up to a year's worth of data (365 days).

Resource URL

GET rws/api/v{apiVersion}/devices/{iccid}/auditTrails

Request Parameters

Request Parameters and Descriptions
Parameter Description
apiVersion

The version number for this API. The current version for all functions is 1.

iccid The ICCID of the device you want information about.
daysOfHistory (Optional) Specifies the audit history time period as measured from today. You can request up to a year's worth of data (no more than 365 days). If you do not specify the number of days, Control Center returns data from the past 30 days by default.
pageSize

(Optional) Specifies the number of records returned in each response page. The maximum value is 50. The value defaults to 50. See Pagination for details.

pageNumber

(Optional) Specifies the number of response pages to return. This value defaults to 1. See Pagination for details.

Response Parameters

The function returns an array of audit history records, with the most recent listed first.

Return Values and Descriptions
Return Value Description
iccid The ICCID of the device.
timestamp The time when the audit information was returned. The date format is yyyy-MM-ddTHH:mm:ss.SSSZ. See Date Formats for more details.

pageNumber

An integer specifying the number of the current page. See Pagination for details.

lastPage

A true or false value indicating whether the current page is the last in the series. See Pagination for details.

deviceAuditTrails An array of change records for the specified device.
Fields within each change record
field The name of the field whose value was changed.
priorValue The previous value of the field. No value indicates that this is the first time the field was set.
value The current value of the field.
effectiveDate The date and time the change occurred. The date format is yyyy-MM-ddT HH:mm:ss.SSSZ. See Date Formats for more details.
status The status of the change. Valid values include: Pending, Running, Executed, Error, Deleted, Cancelled, and WaitingRetry.
userName The name of the user who performed the change.
delegatedUser The name of the user, if any, who acted on behalf of the person who performed the change. This information will alert you if one user was mirroring another when the change occurred.
ipAddress The IP address of the machine used by the person who made the change.

Request Example

Make sure to use your own user credentials. See Authentication for information about creating an authorization header.

json
Copycurl -X GET --header "Accept: application/json" --header "Authorization: Basic <YOUR-ENCRYPTED-CREDENTIALS>" "https://rws-jpotest.jasper.com/rws/api/v1/devices/9901310650450118011/auditTrails?daysOfHistory=30&pageSize=50&pageNumber=1"

Response Example

json
Copy{
  "iccid":"9901310650450118011",
  "timeStamp":"2016-12-06T15:58:06.466Z",
  "pageNumber": 1,
  "lastPage": true,
  "deviceAuditTrails":[   
	{   
	    "field":"Usage Limit Reached",
		"priorValue":"false",
		"value":"false",
		"effectiveDate":"2016-12-06T01:34:16.613Z",
		"status":"Executed",
		"userName":"simUsageManagementUser",
		"delegatedUser":"",
		"ipAddress":"10.106.232.184"
	},
	{   
		"field":"Rate Plan",
		"priorValue":"Integration Test -- SP1 Default RP",
		"value":"Integration Test -- SP1 PrepaidTerm",
		"effectiveDate":"2016-11-11T03:39:06.570Z",
		"status":"Executed",
		"userName":"businessRuleUser",
		"delegatedUser":"",
		"ipAddress":"127.0.0.1"
	}
  ]									
}

Code Samples

Make sure to use the Control Center sandbox URL and your own user credentials.

python
javascript
ruby
Copyimport requests 
import json 
import base64 
import pprint 

cobrandURL=input("Cobrand URL: ")						
url = 'https://'+cobrandURL+'/rws/api/v1/devices/'+input("iccid: ")+'/auditTrails' 
myResponse = requests.get(url,auth=(input("username: "),input("api_key: ")))
# For successful API call, response code will be 200 (OK)
if(myResponse.ok):
    # Loading the response data into a dict variable
    # json.loads takes in only binary or string variables so using content to fetch binary content
    # Loads (Load String) takes a Json file and converts into python data structure (dict or list, depending on JSON)
    jData = json.loads(myResponse.content)
    pp=pprint.PrettyPrinter(indent=4) 
    pp.pprint(jData) 
else:
    # If response code is not ok (200), print the resulting http error code with description
    print("Failure")
    myResponse.raise_for_status()
Copyvar request = require('request');
var body = [];
request.get('https://<your-base-URL>/rws/api/v1/devices/8988216716970004975/auditTrails').auth('username', 'password', false)
    .on('error', function(error){
        console.log('Error:', error);
    })
    .on('response', function(response) {
        console.log(response.statusCode); // return statusCode
        console.log(response.headers['content-type']); // return contentType
    })
    .on('data',function(chunk){
        body.push(chunk);
    })
    .on('end',function(){
        body = Buffer.concat(body).toString();
        console.log(body);
    });
Copy#!/usr/bin/ruby -w
require 'rest-client'
require 'json'
  
url = 'https://<your-base-URL>/rws/api/v1/devices/89011704252318147060/auditTrails'
response = RestClient::Request.execute(
 method: :get,
 url: url,
 user: 'username',
 password: 'password',
 :headers => {:accept => :json}
)
puts JSON.pretty_generate(JSON.parse(response))

Errors

Error Codes, HTTP Codes, and Descriptions
Error Code HTTP Code Error Message
10000001 401

Invalid credentials.

Description: Control Center uses this error message when the API credentials are invalid or when the IP address is not within the allowed range.

10000006 400 Invalid pageSize.
10000007 400 Invalid pageNumber.
10000024 400 Invalid apiVersion.
10000049 400 The daysOfHistory must be less than or equal to 365.
20000001 404 Resource not found - Invalid ICCID.
30000001 500 Unknown server error.