Get Session Details
Description
Returns information about the current or most recent data session for a given device.
Resource URL
GET rws/api/v{apiVersion}/devices/{iccid}/sessionInfo
Request Parameters
| 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. |
Response Parameters
| Return Value | Description |
|---|---|
| iccid | The ICCID of the device. |
| dateSessionStarted |
The time when the current or most recent data session began. For a device that has never had a session, this date is null. |
| dateSessionEnded |
The time when the most recent data session ended. For a device currently in a session, this field is null. For a device that has never had a session, this date is null. |
| ipAddress |
The IPv4 address used by the device during the current or most recent session. A session has at least one IP Address value (ipAddress or ipv6Address) and, in some cases, may have values for both fields. This field is always returned, even if the device does not have an IPv4 address. For a device that has never been in session, this field is null. |
| ipv6Address |
The IPv6 address used by the device during the current or most recent session. A session has at least one IP Address value (ipAddress or ipv6Address) and, in some cases, may have values for both fields. This field is returned only when the device has an IPv6 address. The field never has a null value. |
Request Example
Make sure to use your own user credentials. See Authentication for information about creating an authorization header.
curl -X GET --header "Accept: application/json" --header "Authorization: Basic <YOUR-ENCRYPTED-CREDENTIALS>" "https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975/sessionInfo"
Response Example
{
"iccid": "8988216716970004975",
"ipAddress": "null",
"ipv6Address": "2605:9780:309e::/64",
"dateSessionStarted": "2016-07-06 01:31:46.893+0000",
"dateSessionEnded": "2016-07-06 01:31:46.893+0000"
}
Code Samples
Make sure to use the Control Center sandbox URL and your own user credentials.
import requests
import json
import base64
import pprint
cobrandURL=input("Cobrand URL: ")
url = 'https://'+cobrandURL+'/rws/api/v1/devices/'+input("iccid: ")+'/sessionInfo'
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()var request = require('request');
var body = [];
request.get('https://<your-base-URL>/rws/api/v1/devices/8988216716970004975/sessionInfo').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);
});#!/usr/bin/ruby -w
require 'rest-client'
require 'json'
url = 'https://<your-base-URL>/rws/api/v1/devices/89011704252318147060/sessionInfo'
response = RestClient::Request.execute(
method: :get,
url: url,
user: 'username',
password: 'password',
:headers => {:accept => :json}
)
puts JSON.pretty_generate(JSON.parse(response))
Errors
| 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. |
| 10000024 | 400 | Invalid apiVersion. |
| 10000031 | 400 | Invalid Zone. |
| 20000001 | 404 | Resource not found - Invalid ICCID. |
| 30000001 | 500 | Unknown server error. |