### Search Devices - Request Example Source: https://developer.cisco.com/docs/control-center/search-devices Example of how to make a GET request to search for devices, specifying account ID, modification date, and page size. ```bash curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/devices?accountId=100020620&modifiedSince=2016-04-18T17%3A31%3A34%2B00%3A00&pageSize=50&pageNumber=1" ``` -------------------------------- ### Echo Request Example (cURL) Source: https://developer.cisco.com/docs/control-center/echo Example of how to make a GET request to the Echo endpoint using cURL to retrieve a response. ```bash curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/echo/hello-world" ``` -------------------------------- ### Get SMS Details Request Example Source: https://developer.cisco.com/docs/control-center/get-sms-details Example of how to make a GET request to retrieve SMS message details using cURL. It includes the necessary headers for authentication and content type. ```curl curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/smsMessages/106184" ``` -------------------------------- ### Retrieve Rate Plans using cURL Source: https://developer.cisco.com/docs/control-center/get-rate-plans Example cURL command to fetch rate plan data from the Cisco Control Center API. It demonstrates how to set the HTTP method, headers (Accept and Authorization), and the API endpoint with pagination parameters. ```bash curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https:///rws/api/v1/rateplans?pageSize=50&pageNumber=1" ``` -------------------------------- ### Search Devices - Response Example Source: https://developer.cisco.com/docs/control-center/search-devices Example JSON response when searching for devices, showing device details like ICCID, status, rate plan, and communication plan. ```json { "pageNumber": 1, "devices": [ { "iccid": "8988216716970004971", "status": "ACTIVATION_READY", "ratePlan": "hphlr rp1", "communicationPlan": "CP_Basic_ON" }, { "iccid": "8988216716970004975", "status": "ACTIVATED", "ratePlan": "hphlr rp1", "communicationPlan": "CP_Basic_ON" } ], "lastPage": true } ``` -------------------------------- ### Get SMS Details Response Example Source: https://developer.cisco.com/docs/control-center/get-sms-details Example JSON response containing the details of a specific SMS message, including its ID, status, content, sender, recipient, and timestamps. ```json { "smsMsgId": 106184, "status": "Pending", "messageText": "Hello world", "senderLogin": "dpTrialUser2", "iccid": "8988216716970004975", "sentTo": "882351697004975", "sentFrom": "Server", "msgType": "MT", "dateSent": "2016-07-06 16:05:16.280-0700", "dateModified": "2016-07-06 16:05:16.522-0700" } ``` -------------------------------- ### API Response Example Source: https://developer.cisco.com/docs/control-center/create-customers This snippet shows a typical JSON response received after successfully creating a customer via the Cisco Control Center API. It includes the customer ID and a timestamp. ```json { "customerId": 1234, "timestamp": 1527590173 } ``` -------------------------------- ### Fetch Rate Plans with Ruby Source: https://developer.cisco.com/docs/control-center/get-rate-plans This Ruby script utilizes the 'rest-client' and 'json' gems to access the Cisco Control Center API for rate plans. It performs a GET request with basic authentication and pretty-prints the JSON response. ```ruby #!/usr/bin/ruby -w require 'rest-client' require 'json' url = 'https:///rws/api/v1/rateplans?accountId=acct_id&pageSize=page_size&pageNumber=page_number' response = RestClient::Request.execute( method: :get, url: url, user: 'user_name', password: 'password', :headers => {:accept => :json} ) puts JSON.pretty_generate(JSON.parse(response)) ``` -------------------------------- ### Get Device Session Details (cURL) Source: https://developer.cisco.com/docs/control-center/get-session-details Example using cURL to fetch session information for a device by its ICCID. Requires authentication credentials. ```shell curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975/sessionInfo" ``` -------------------------------- ### Get Device Information with Ruby Source: https://developer.cisco.com/docs/control-center/get-device-details This Ruby code snippet illustrates how to fetch device data from the Cisco Control Center API. It utilizes the 'rest-client' and 'json' gems to make the GET request and parse the JSON response, respectively. Authentication is handled via basic authentication. ```ruby #!/usr/bin/ruby -w require 'rest-client' require 'json' url = 'https:///rws/api/v1/devices/89011704252318147060' response = RestClient::Request.execute( method: :get, url: url, user: 'username', password: 'password', :headers => {:accept => :json} ) puts JSON.pretty_generate(JSON.parse(response)) ``` -------------------------------- ### Partial Response with All Subfields Source: https://developer.cisco.com/docs/control-center/getting-started Demonstrates how to retrieve all subfields for a customer by using the 'fields=field1/*' syntax. This is useful for getting comprehensive customer details. ```json { "name": "Northwest Region", "contacts": [ { "name": "John Doe", "email": "jdoe@acme.com" }, { "name": "Annette Wong", "email": "awong@acme.com" } ] "billingAddress": { "addressLine1": "593 Palm Dr.", "addressLine2": null, "city": "Los Angeles", "state": "CA", "country": "USA", "postalCode": "91201" } } ``` -------------------------------- ### API Error Response Example Source: https://developer.cisco.com/docs/control-center/getting-started Illustrates a typical error response from the Cisco Control Center API, including an error message and a specific error code. ```json { "errorMessage": "The API credentials are not valid.", "errorCode": "10000001" } ``` -------------------------------- ### Get Device Details Request Example (cURL) Source: https://developer.cisco.com/docs/control-center/get-device-details This snippet demonstrates how to make a GET request to the Cisco IoT Control Center API to retrieve details for a specific device. It requires authentication credentials and the device's ICCID. ```cURL curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975" ``` -------------------------------- ### Fetch Rate Plans using Python Source: https://developer.cisco.com/docs/control-center/get-rate-plans This Python script uses the 'requests' library to make a GET request to the Cisco Control Center API to retrieve rate plan information. It includes parameters for account ID, page size, and page number, and uses basic authentication with username and API key. ```python import requests import json import base64 import pprint apiUrl= 'https:///rws/api/v1/rateplans' parameters= {'accountId':"acct_id", 'pageSize': "page_size", 'pageNumber': "page_number"} myResponse = requests.get(url=apiUrl, auth=(raw_input("username: "),raw_input("api_key: ")), params=parameters) ``` -------------------------------- ### Request Usage for a Specific Cycle Start Date Source: https://developer.cisco.com/docs/control-center/get-device-usage-by-zone This cURL command retrieves usage records for a device, filtered by a specific cycle start date. Authentication with user credentials is required. ```curl curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/devices/8988217755520000031/usageInZone?cycleStartDate=2016-11-10Z" ``` -------------------------------- ### Get Device Information with JavaScript Source: https://developer.cisco.com/docs/control-center/get-device-details This JavaScript snippet demonstrates how to fetch device information from the Cisco Control Center API using the 'request' library. It includes error handling, response status code, content type logging, and data retrieval. ```javascript var request = require('request'); var body = []; request.get('https:///rws/api/v1/devices/8988216716970004975').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); }); ``` -------------------------------- ### Send SMS using cURL Source: https://developer.cisco.com/docs/control-center/send-sms Example of sending an SMS message using the cURL command-line tool. It demonstrates the POST request with necessary headers and a JSON payload. ```bash curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Basic " -d "{ \"messageText\": \"Hello world\" }" "https://rws-jpotest.jasper.com/rws/api/v1/devices/89302720396916018117/smsMessages" ``` -------------------------------- ### Get Device ICCID, Status, and Rate Plan (Multiple Fields) Source: https://developer.cisco.com/docs/control-center/getting-started Fetches multiple fields (iccid, status, ratePlan) for a device. The 'fields=' parameter lists the desired attributes separated by commas, with no spaces. ```HTTP https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975?fields=iccid,status,ratePlan ``` -------------------------------- ### Get Rate Plans via Cisco IoT Control Center API Source: https://developer.cisco.com/docs/control-center/sms-messages Fetches a list of available rate plans through the Cisco IoT Control Center REST API. ```shell GET /rate-plans ``` -------------------------------- ### Get Device Usage Details (Python) Source: https://developer.cisco.com/docs/control-center/get-device-usage Fetches cycle-to-date usage data for a device using Python's requests library. It prompts for the cobrand URL, ICCID, username, and API key for authentication. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") ``` -------------------------------- ### Python: Get Device Usage Data Source: https://developer.cisco.com/docs/control-center/get-device-usage-by-zone This Python script demonstrates how to fetch device usage data from the Cisco Control Center API using the `requests` library. It handles authentication and pretty-prints the JSON response. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") ``` -------------------------------- ### API Coding: Response Best Practices Source: https://developer.cisco.com/docs/control-center/rest-api-troubleshooting-checklist This section advises on best practices for API response coding, including preparing for unexpected items in the response. Cisco may introduce new return values to the APIs, so code should be flexible. ```General Ensure that your code allows for additional, unexpected items in the response. Cisco may add new return values to the APIs. ``` -------------------------------- ### Cisco IoT Control Center Code Samples Source: https://developer.cisco.com/docs/control-center/resources Access code samples for common Cisco IoT Control Center tasks. These samples are hosted on GitHub and can be leveraged to accelerate development. ```GitHub https://github.com/ciscosystems/iot-control-center-samples ``` -------------------------------- ### API Setup: Authorization Header Source: https://developer.cisco.com/docs/control-center/rest-api-troubleshooting-checklist This section details the process for creating a valid authorization header for API requests. It involves concatenating the username and API key, encrypting the string using Base64, and formatting the header value. ```General 1. Concatenate the user name and API key (separated by a colon) 2. Encrypt the resulting string using Base64 3. Set the authorization header value to "Basic" followed by the encoded string. ``` -------------------------------- ### Get Device Status (Single Field) Source: https://developer.cisco.com/docs/control-center/getting-started Retrieves the status of a specific device using the 'fields=' parameter to request only the 'status' field. This is a basic example of partial response. ```HTTP https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975?fields=status ``` -------------------------------- ### Get Usage by Rate Plan - Cisco IoT Control Center API Source: https://developer.cisco.com/docs/control-center/get-usage-by-rate-plan Retrieves usage information for a specific rate plan within a given billing cycle. Supports filtering by usage type, billing cycle start date, and rate plan version. Note that shared rate plans are not supported. ```HTTP GET rws/api/v{apiVersion}/usages?ratePlanName={ratePlanName}&cycleStartDate={yyyy-MM-dd}&usageType={DATA|SMS|VOICE}&ratePlanVersion={version}&pageNumber={pageNumber}&pageSize={pageSize} ``` -------------------------------- ### Get Device Usage by Zone Source: https://developer.cisco.com/docs/control-center/get-device-usage-by-zone Retrieves usage information for a specified device within a single billing cycle, broken down by rate plan and zone. Supports filtering by zone and/or rate plan, and specifying a billing cycle start date. Returns usage for the current billing cycle by default if no date is specified. ```REST GET rws/api/v{apiVersion}/devices/{iccid}/usageInZone ``` -------------------------------- ### Get SMS Details Python Code Sample Source: https://developer.cisco.com/docs/control-center/get-sms-details Python code snippet to retrieve SMS message details using the requests library. It demonstrates how to construct the URL and make a GET request with authentication. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") ``` -------------------------------- ### Create Customer - Cisco IoT Control Center API Source: https://developer.cisco.com/docs/control-center/create-customers This snippet demonstrates how to create a new customer using the Cisco IoT Control Center REST API. It includes the resource URL and details the required and optional request parameters for customer creation, including contact and address information. ```HTTP POST rws/api/v{apiVersion}/customers ``` -------------------------------- ### Ruby: Get Device Session Info with RestClient Source: https://developer.cisco.com/docs/control-center/get-session-details This Ruby script utilizes the 'rest-client' and 'json' gems to retrieve device session information from the Cisco Control Center API. It makes a GET request with authentication and pretty-prints the JSON response. ```ruby #!/usr/bin/ruby -w require 'rest-client' require 'json' url = 'https:///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)) ``` -------------------------------- ### Get Rate Plans REST API Request Source: https://developer.cisco.com/docs/control-center/get-rate-plans This snippet shows how to make a GET request to the Cisco IoT Control Center API to retrieve rate plan details. It includes the resource URL and optional query parameters for pagination and account filtering. ```REST GET rws/api/v{apiVersion}/rateplans?accountId={accountId}&pageSize={pageSize}&pageNumber={pageNumber} ``` -------------------------------- ### Fetch Rate Plans with Python Source: https://developer.cisco.com/docs/control-center/get-rate-plans This Python script demonstrates how to make an API call to retrieve rate plans from the Cisco Control Center. It handles successful responses by parsing JSON data and prints it using pretty-printing. For unsuccessful responses, it raises an HTTP error. ```python import requests import json import pprint # Assuming myResponse is a response object from a requests.get call # Example: myResponse = requests.get(url, auth=(user_name, password)) 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) pp = pprint.PrettyPrinter(indent=4) jData = json.loads(myResponse.content) pp.pprint(jData) else: # If response code is not ok (200), print the resulting http error code with description myResponse.raise_for_status() ``` -------------------------------- ### Request Usage for Specific Date, Rate Plan, and Zone Source: https://developer.cisco.com/docs/control-center/get-device-usage-by-zone This cURL command fetches usage data for a device, specifying the cycle start date, rate plan, and zone. Ensure you use your own encrypted credentials for authentication. ```curl curl -X GET --header "Accept: application/json" --header "Authorization: Basic " "https://rws-jpotest.jasper.com/rws/api/v1/devices/8988217755520000031/usageInZone?cycleStartDate=2016-11-10Z&ratePlan=Rate%20Plan%20A&zone=Zone%20B" ``` -------------------------------- ### Control Center Sandbox API URL Source: https://developer.cisco.com/docs/control-center/frequently-asked-questions-faqs This snippet provides the base URL for accessing the Cisco Control Center sandbox APIs. It is essential for making any requests to the sandbox environment. ```text https://rws-jpotest.jasper.com/rws/api/ ``` -------------------------------- ### Get Device Session Details (Python) Source: https://developer.cisco.com/docs/control-center/get-session-details Python script to retrieve device session details using the requests library. It prompts for the Cobrand URL, ICCID, username, and API key for authentication. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") ``` -------------------------------- ### Create Customer API Request Source: https://developer.cisco.com/docs/control-center/create-customers This snippet shows a curl command to make a POST request to the Cisco Control Center API to create a new customer. It includes the necessary headers for content type, acceptance, and authorization, along with a JSON payload containing customer details. ```curl curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Basic " -d "{ \"name\": \"Acme Customer\", \"accountName\": \"Acme\", \"securityQuestion\": \"FirstConcert\", \"securityAnswer\": \"Journey\", \"shipToBillAddress\": true, \"billingAddress\": { \"addressLine1\": \"123 Main\", \"addressLine2\": \"string\", \"city\": \"Anytown\", \"state\": \"FLA\", \"country\": \"USA\", \"postalCode\": \"36301\" } }" "https://rws-jpotest.jasper.com/rws/api/v1/customers" ``` -------------------------------- ### Ruby: Fetch SMS Messages from Cisco Control Center API Source: https://developer.cisco.com/docs/control-center/get-sms-details This Ruby script utilizes the 'rest-client' and 'json' gems to retrieve SMS messages from the Cisco Control Center API. It performs a GET request with basic authentication and pretty-prints the JSON response. ```ruby #!/usr/bin/ruby -w require 'rest-client' require 'json' url = 'https://rws-jpotest.jasper.com/rws/api/v1/smsMessages/25830319302' response = RestClient::Request.execute( method: :get, url: url, user: 'username', password: 'password', :headers => {:accept => :json} ) puts JSON.pretty_generate(JSON.parse(response)) ``` -------------------------------- ### Python: Get Device Session Info and Handle Response Source: https://developer.cisco.com/docs/control-center/get-session-details This Python script retrieves device session information from the Cisco Control Center API. It checks the response code, parses JSON data, and prints it using pretty-printing. If the response code is not OK, it raises an HTTP error. ```python import json import pprint # Assuming myResponse is a response object from a request library 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() ``` -------------------------------- ### Fetch Devices using Python Source: https://developer.cisco.com/docs/control-center/search-devices This Python script uses the requests library to fetch device information from the Cisco Control Center API. It requires user credentials and a cobrand URL. The script handles successful responses by pretty-printing the JSON data and raises an error for failed requests. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") ``` -------------------------------- ### Get Device Information with Python Source: https://developer.cisco.com/docs/control-center/get-device-details This Python script shows how to retrieve device details from the Cisco Control Center API. It uses the 'requests' library for HTTP calls and 'json' for parsing the response. The script prompts for user input for the base URL, ICCID, username, and API key. ```python import requests import json import base64 import pprint cobrandURL=input("Cobrand URL: ") url = 'https://'+cobrandURL+'/rws/api/v1/devices/'+input("iccid: ") 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() ``` -------------------------------- ### API Performance: Pagination Source: https://developer.cisco.com/docs/control-center/rest-api-troubleshooting-checklist This guidance addresses API performance, specifically concerning pagination. The page size is limited to 50 records, and code must handle this limitation effectively. ```General Page size is limited to 50 records. Make sure your code handles pagination properly. ``` -------------------------------- ### Get Device Audit History Response (JSON) Source: https://developer.cisco.com/docs/control-center/get-device-audit-history This JSON object represents a successful response from the Cisco IoT Control Center REST API when requesting device audit history. It includes device information, pagination details, and an array of audit trail records detailing changes made to the device. ```json { "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" } ] } ``` -------------------------------- ### Get Rate Plans Cisco IoT Control Center Source: https://developer.cisco.com/docs/control-center/rate-plans This section describes how to retrieve information about available rate plans in the Cisco IoT Control Center. It details the structure of rate plans, including subscription types, included usage, services, fees, and zone-specific charges. ```REST API GET /rateplans ``` -------------------------------- ### Node.js: Get Device Session Info with Request Module Source: https://developer.cisco.com/docs/control-center/get-session-details This Node.js script uses the 'request' module to fetch device session information from the Cisco Control Center API. It handles errors, logs the response status code and content type, and concatenates response chunks before printing the body. ```javascript var request = require('request'); var body = []; request.get('https:///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); }); ```