The direct route is used to call single function with direct authentication. Every function call must be authenticated. This route can only be used for simple functions that do not require events.

First Steps

The most simple example is to get the properties of a user with http GET. Just paste the following line in a browser window. You will be prompted for authentication. Use a UCServer user name and password to authenticate. The result will be a json struct that contains the attributes of the user.


Authentication options

There are different authentication options available.

  • HTTP Basic Authentication
    When using HTTP Basic Authentication in the Browser, a prompt will ask the user for credentials.

  • Token Authentication
    Token Authentication is used to authenticate users without transmitting the password every time. A Login Token can be obtained with asnGetUserToken. The Token is transmitted either with a query parameter (http://localhost:7224/ws/direct/asnGetLoggedInContact?token=aabbccddeeff) or as HTTP custom header (x-uctoken: aabbccddeeff). When using this option, no 401 response will be given. Failed Authentication will result in a 400 response with an json error struct.
    Replace aabbccddeeff with the login token:
  • Username and Password in query
    Username and Password may be transmitted as query parameters. When using this option, no 401 response will be given. Failed Authentication will result in a 400 response with an json error struct.
    Replace username and password with valid credentials:

Using Javascript

You may Javascript to send commands to the server. Copy the following text to a html file and open it in the browser. You may also open the page here: Open Page.;

<!DOCTYPE html>
    span { vertical-align: top; display: inline-block; width: 200px; }
    input { display: inline-block; width: 400px; }
      <span>Server URL:</span><input id="serverurl" value="http://localhost:7224"/><br/>
      <span>Username:</span><input id="user" value=""/><br/>
      <span>Password:</span><input id="pass" value=""/><br/>
      <span>Function:</span><input id="func" value="asnGetLoggedInContact"/><br/>
      <span>Params:</span><textarea rows="7" id="params">{ }</textarea><br/>
      <button type='submit' onclick='sendcommand(); event.preventDefault();'>Send Command</button><br/>
    <pre id="result"></pre>
    function sendcommand()
      var serverurl = document.getElementById("serverurl").value;
      var user = document.getElementById("user").value;
      var pass = document.getElementById("pass").value;
      var func = document.getElementById("func").value;
      var params = document.getElementById("params").value;
      try {
      } catch(e) {
        document.getElementById("result").innerHTML = 'Failed: Params are not valid JSON: ' + e;
      var oXHR = new XMLHttpRequest();   // new HttpRequest instance
      oXHR.addEventListener("loadend", function(evt) {
        var outtext = oXHR.responseText;
        try {
          outtext = JSON.stringify(JSON.parse(oXHR.responseText), null, 4);        
        } catch(e) {
        if (oXHR.status == 0) {
          document.getElementById("result").innerHTML = 'Failed: General Network Error';
        } else if (outtext == '') {
          document.getElementById("result").innerHTML = 'Failed: No response received';
        } else if (oXHR.status == 200) {
          document.getElementById("result").innerHTML = outtext;
        } else {
          document.getElementById("result").innerHTML = outtext;
      var querystring = '?user=' + encodeURIComponent(user) + '&pass=' + encodeURIComponent(pass);
      oXHR.open("POST", serverurl + "/ws/direct/" + func + querystring);
      oXHR.setRequestHeader("Content-Type", "application/json;charset=utf-8");

Using cURL

You may use cURL (http command line) to send commands to the server. cURL can be found for multiple operating systems on the internet.

curl.exe "http://localhost:7224/ws/direct/asnGetLoggedInContact?user=username&pass=password" -X POST -H "Content-Type: application/json" -d "{ }"

curl.exe "http://localhost:7224/ws/direct/asnGetLoggedInContact?user=username&pass=password"

All API endpoints may be called with GET or POST. Jsonp is supported.

Version 6.4