Showing results for 
Search instead for 
Did you mean: 


To make it easier to integrate with the Context Service, a new sample has been uploaded to GitHub.  It provides an example of how you could write a REST API on top of the Java Context Service SDK.  This is useful for situations where you are using Javascript, .NET,  PHP or some other language and want to be able to perform create, update, and search (and in lab mode, delete) on Context Service objects.

You can find the webapp sample here:

The sample itself includes code to create two webapps:

  • REST API webapp (rest.war) - exposes a REST API
  • Management Connector webapp (management.war) - handles registration/deregistration and credentials changed listener

Note: The sample does not provide multi-tenancy (only one organization can be serviced by an instance of this webapp).

Handling Connection Data Changes

The sample CredentialsChangedListener is implemented in, and its logic is crucial to ensure your application's connection data is up to date.  Connection data is renewed every 270 days, so if you do not have a listener registered in your application to update it, the SDK will not initialize successfully if the connection data has expired.

You can find an example CredentialsChangedListener in the sample's ManagementContextListener class, which stores the connection data in a properties file in the local file system.  This is just an example, and it is recommended to store the connection data more securely and perhaps centrally (for instance, shared DB) in the case where your SDK webapp is hosted on multiple machines.

Note: Connection data should not be shared as it contains sensitive data.


The sample also demonstrates how to implement registration in your application.  First you call RegisteringApplication.createRegistrationRequest() to get a URL (see  Your application should then direct the user to this URL (see app.js).  After an organization admin authenticates, the user's browser is redirected back to the callback URL.  In the sample, the RegistrationService saveConnectionData() method handles the callback to 1) save the connection data, and 2) initialize the management connector via ManagementConnector.init().


The sample provides create/retrieve/update/delete/search via REST.  (Custom fields and field sets to be used by context objects can be managed in the Cisco Spark Administration webapp by organization admins.)

For example, to create a new activity (pod), execute a POST request like this:

POST http://localhost:8080/rest


"type" : "pod",

"fieldsets": ["cisco.base.pod"],

"dataElements": [


            "key": "Context_Notes",

            "value": "testing at 3:16"




See the file for more information.

Note: No authentication is provided on this REST API.  Depending on where the application is hosted, it is recommended that you include authentication (such as basic auth) in your implementation.

Deployment to Tomcat

Sample scripts make it easy to get started quickly.  The sample has a script that configures 2 instances of Tomcat, one to host the REST API, and the other to host the Management Connector webapp.

Note: The scripts are intended for Mac/Linux, but could be adapted for Windows.

Once the Tomcat instances are prepared properly, two scripts can be used to start and stop Tomcat ( and The application can be accessed at the following URLs:

Tomcat logs can be found in:

  • Webapp_Sample_Project/Deploy_Server/rest-tomcat/logs/catalina.out
  • Webapp_Sample_Project/Deploy_Server/management-tomcat/logs/catalina.out

We hope you enjoy the new sample, and please let us know if you have any questions!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Recognize Your Peers