Skip to main content
Skip table of contents

Accessing and invoking policy console resources

Because the policy console is RESTful, every object has a URL—for example, each APK and IPA app you upload, each policy that you can apply to an app, each policy profile, and each user account has its own URL.

If you want details on an app, policy, profile, or user, you GET that object's URL using a fully qualified domain name (or IP address) of your policy console. For example:

BASH
GET https://bc.qwe.com/mocana-app-control/rest/app-policy/0a22067f-d523-4864-8973-3a80f054d884


These URLs often include the Globally Unique IDentifier (GUID) assigned to the object (such as 0a22067f-d523-4864-8973-3a80f054d884 shown in this example).

Access resources with HTTPS requests; the policy console responds with JSON-formatted data.

Forming requests

Access services with HTTPS methods:

  • POST and PUT create or update resources.
  • GET reads resources or performs list operations that may return multiple items.
  • DELETE removes resources from the policy console.

The API Resources section describes the available HTTPS methods.

cURL examples

Most examples in this documentation use cURL, an open-source command line tool, to demonstrate HTTPS requests. cURL is available for many operating systems at curl.haxx.se, but your code can be written with any tools capable of sending HTTPS requests.

Server responses

JSON format

Policy console API resources return data in JavaScript Object Notation (JSON), a lightweight, language-independent data-interchange format. Libraries for parsing JSON data exist for all major programming languages. See json.org for a JSON overview and reference guide.

Response fields

All server responses contain at least two fields: 

  • status: A string with value OK or Error.
  • message: Often empty for responses where status is OK. If status is Error, message can contain an error message.

Errors

Error messages can help you debug when things aren't working. Errors can come in the response message field, or as a block of HTML.

Invalid or missing parameters

One common type of API error occurs when the programmer forgets to specify a required parameter or uses an invalid value for a parameter. Here are some examples of the error codes that return.

If you do not specify a password when creating a user, you see this error:

JS
{
  "errors": [{
    "code": 103,
    "message": "Password cannot be empty!",
    "source": "password"
  }],
  "message": "Validation Error",
  "status": "Error"
}

If you do not specify an ID when updating a user, you get this:

JS
{
  "errors": [{
    "code": 100,
    "message": "ID is required!",
    "source": "id"
  }],
  "message": "Validation Error",
  "status": "Error"
}

Here's a sample with multiple validation errors. If you do not provide an email when updating a user, you get two errors:

JS
{
  "errors": [
  {
    "code": 101,
    "message": "E-mail is required!",
    "source": "email"
  },
  {
    "code": 102,
    "message": "Invalid e-mail!",
    "source": "email"
  }
  ],
  "message": "Validation Error",
  "status": "Error"
}

Invalid URLs

If you enter an invalid URL, you'll see an error report like this, formatted as HTML:

XML
<html><head><title>Apache Tomcat/6.0.24 - Error report</title>
<style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} 
H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} 
H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} 
BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} 
B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} 
P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}
A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head>
<body>< HTTP Status 404 - /mocana-app-control/rest/user/list</h1><HR size="1" noshade="noshade">
<p><b>type</b> Status report</p><p><b>message</b> <u>/mocana-app-control/rest/user/list</u></p><p><b>description</b> 
<u>The requested resource (/mocana-app-control/rest/user/list) is not available.</u></p><HR size="1" noshade



JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.