Cisco Unity Connection has a set of feature-rich APIs to accomplish various tasks:
Most of these APIs function very similarly. They are all REST-based and can typically respond with either JSON or XML in the response body. As mentioned above, the API for managing and provisioning a Unity Connection system is the CUPI API. Most of the other APIs simply add more functionality for specific use cases and types of server or client data.
NOTE: this lab will focus entirely on features exposed by the supported APIs, which means it is not a direct database query/request. Unity Connection does have some ability to do this using tools such as the Cisco Utilities Data Link for Informix (CUDLI) and/or the Python Scripting Host, however these tools are generally meant to handle specific one-off scenarios and are not part of this lab and should not be used for regular, ongoing automation tasks.
In this section, you will perform the following tasks:
In Unity Connection, users can either be created manually or imported either via LDAP or via a CUCM server using AXL. For this lab, you will use LDAP. For this, the LDAP synchronization between Unity and the LDAP server is already set up. When synchronization occurs, Unity simply learns about those users that exist in LDAP and are available for import, which is to say, have actual accounts with or without a voicemail box created in Unity Connection.
First, generate a query to get the users that can be imported as show in the following steps.
{
"@total": "5",
"ImportUser": [
{
"alias": "Token_User_501dfdf6-2861-4072-a4f8-8abaa0f5b7aa",
"firstName": "",
"lastName": "Token",
"pkid": "8993458a-4a99-47c4-92ec-3f01bfa06942"
},
{
"alias": "pod6user1",
"firstName": "Pod6",
"lastName": "User1",
"pkid": "6ad0a9c9-260a-5663-668f-275a290c8be2"
},
...
Searching in CUPI for users of any type is done via parameters in the URI. The following steps will show you how to add a query for the alias that matches pod6user1 exactly. The part that would need to be added to the URL is ?query=(alias%20is%20pod6user1). If you consider that %20 is the hexadecimal representation of the space character, this is very readable (e.g. ?query=(alias is pod1user1) ). Aside from the is keyword, CUPI also supports startswith in order to perform a wildcard search.
{
"@total": "1",
"ImportUser": {
"alias": "pod6user1",
"firstName": "Pod6",
"lastName": "User1",
"pkid": "6ad0a9c9-260a-5663-668f-275a290c8be2"
}
}
Importing a user, just as creating a user in Unity Connection, consists of a POST request and specifying not only what user should be imported, but also a template to use when creating this user. This is exactly the same in the Unity Connection GUI, since there are so many settings, the system only allows you to add a user using a template that has most settings filled in for you. In the actual Postman request, we need to not only specify parameters, as we did earlier, but also add a body to the request.
{
"dtmfAccessId": "12345",
"pkid": "dbc37047-7565-6b29-3327-18850f64d406"
}
/vmrest/users/3967c91f-30ee-4656-83ac-3bc4600ee0dd
This occurs despite that your request still has an Accept header with "application/json". However, since this is the reply to
a POST instead of a GET, the response is different and you need to be able to handle this
kind of response, as well.
{
"@total": "1",
"User": {
"URI": "/vmrest/users/3967c91f-30ee-4656-83ac-3bc4600ee0dd",
"ObjectId": "3967c91f-30ee-4656-83ac-3bc4600ee0dd",
"FirstName": "Pod6",
"LastName": "User1",
"Alias": "pod6user1",
"City": "",
"Department": "31",
"DisplayName": "Pod6 User1",
...
"ListInDirectory": "true",
...
"DtmfAccessId": "12345",
...
"UserVoicePinURI": "/vmrest/users/3967c91f-30ee-4656-83ac-3bc4600ee0dd/credential/pin",
...
You have also see the ListInDirectory and DisplayName settings, which you
will modify next. The PKID for this user account is in the ObjectId field. It is the same ID
that was returned when importing/creating the account using the LDAP user.
Copy this user PKID (ObjectID) value from your response for the next step
Modifying most user settings is not difficult. It requires the PUT request and information in the Body indicating what settings to change. Not all settings can be modified. Some things, such as the alias, first name / last name, and password are controlled in LDAP because you chose to import that user instead of creating the user from scratch, where everything can be specified and modified.
{
"DisplayName": "Updated User",
"ListInDirectory": "false"
}
{
"@total": "1",
"User": {
"URI": "/vmrest/users/3967c91f-30ee-4656-83ac-3bc4600ee0dd",
...
"DisplayName": "Updated User",
...
"ListInDirectory": "false",
...
Updating a voicemail user's PIN and unlocking the mailbox is one of the most common administrator tasks. PINs can be forgotten, and after repeated failed attempts, a mailbox is locked for some time. Luckily, unlocking the mailbox and changing the PIN is no more difficult than other user setting updates. Note that existing passwords and PINs can never be retrieved, however they can be changed, if they were forgotten. Also be aware that in this lab scenario, the user voicemail accounts are imported from our LDAP directory. User passwords, not the PIN, are utilizing LDAP authentication, so they cannot be changed in Unity Connection (either via the GUI or API). If these were stand-alone users not tied to LDAP, then that would, of course, be possible.
{
"Credentials": "14235834",
"HackCount": 0,
"TimeHacked": []
}
This sets the PIN credential and unlocks the account by resetting the HackCount
and TimeHacked settings (the latter being set to a blank value).
{
"errors": {
"code": "DATA_EXCEPTION",
"message": "Password does not have enough characters",
"DetailCode": "19"
}
}
Deleting a user is simple, as expected. It requires a DELETE operation sent to the /vmrest/users/ URL followed by the pkid of the user account to be deleted. Note that this simply deletes the account in Unity Connection. In this case, this same user would then be available to be re-imported via LDAP.
Feel free to close some or all of the requests in Postman at this time (no need to save anything), as you will be adding more in the next section.
Now that you are familiar with Unity Connection's CUPI API, you can dive into the Cisco Meeting Server (CMS) API, another REST-based API.