Connecting to CCA Web API with POSTMAN
Postman is a REST API client, which allows you to generate queries to web API's, and read responses sent back. It is a convenient tool to play around with APIs before and during the creation of your app.
Pre-requisites
- REST API knowledge.
- Admin account on Supervisor application.
- Admin account on CCA server.
- CCA API's are installed (instructions here).
- Postman installed on your machine.
Setup the environment
- Connect to the CCA platform via Supervisor.
- Open CCA settings.
- Make sure the CCA settings include the CCA API URL. It is given to you during the installation phase, and looks like this: https://{YOUR_SERVER_ADDRESS}/CcaAPI/CcaAPI.Service.svc
Authentication to the API
Creating a permanent token
There are a couple ways to authenticate to the API. The most common one is setting up a permanent authentication token. This token is generated using a combination of a user name + a module. When using this token, you will only be granted privileges that would be granted to this user, in the context of the module.
Here is how to setup your permanent token . . .
- First, from the Modules view, add a new module.
- Set "allow permanent tokens" to "Yes".
- Then, navigate to the Authentication Tokens view and click "Add".
- Put in a description for the token and select the "Agent". Logging in with that token will then be equivalent to logging in with that user's credentials. The user will benefit from the same restrictions, regardless of their authentication method.
- Select the module to which this token will grant access to.
- Make sure to set an expiration date if needed. Once this date is expired, access will be revoked.
- You can then read and use the token contained in the first column. Write it down (it will look like this example string: A-b189a7c5-804d-403f-ac4a-a940dfsfdfs) . . .
- From the "Restriction" panel, make sure that the agent's restriction allows them to use the newly created module.
Using Postman
- Import the following request file into Postman.
- Create a new Postman environment (see how from Postman documentation).
- Give it a friendly name.
- Insert the following key/value pairs:
- URL / {YOUR_SERVER_ADDRESS} e.g. demo.askia.com.
- token / {thetoken_you_just_wrote_down}.
- Select the newly created environment.
- Select one of the queries from the imported collection called "CCA API".
- Hit "send" and check the responses.
WEB API Reference
The reference documentation is included directly in your CCA instance. You can navigate to http://[your server address] / ccawebapi to browse the various REST keywords.
Alternatively, here is a public one: http://demo.askia.com/ccawebapi
Further examples
An alternative authentication method is by using username + password + module
It is achievable by sending a . . .
POST /session
. . . request, whose body contains the following payload . . .
{username: "YOUR_CCA_LOGIN", password: "YOUR_CCA_PASSWORD", module: "YOUR_MODULE_NAME"}
. . . and reading the output token from the response. This token is valid for a specific duration, set in CCA. (By default 1 minute).
Authorization : Bearer {YOUR_TOKEN}
Here is an example implementation of a JS wrapper around this API. You can use this in a sandbox environment to play around with examples.