How to get user roles


I have try to get logged in Users role with the help of this page detail :

But when execute this below lines with my userid-

var requestUrl = "{userid}.xml (or .json)

var xml = webClient.DownloadString(requestUrl);

it throws error- "Unable to connect to the remote server"

can anyone please help me to sort it out.


Parimal Patel

  • Did you update the requestUrl with the URL of your actual site?

  • In reply to Luke D:

    yes i have update it.....

  • In reply to Parimal:

    Hi Luke D,

         could you please tell me what issue exactly occur....

  • In reply to Parimal:

    Any buddy have a solution regarding my issue to get roles of user.

    Thanks & Regard's
  • In reply to Parimal:

    Can you post your actual code? The sample in your original post isn't valid code.
  • In reply to Ben Tiedt:

    Have you set the authentication credentials for the rest api? You won't be able to access the api if you haven't created an api key and are passing this in the header of the request. You could use the widget api to do this also depending on what version of Telligent/Zimbra you are on. As Ben said it would be useful if you posted more of your code and have more details on your version number and where you are trying to run the code.
  • In reply to Ben Tiedt:

    Hi, Ben Tiedt

             Thanks for Reply... 

    My code i have mention below. Please let me know where i need to change.


    //Help Link:
    //Get API and name through this way- Link:

    var adminKey = String.Format("{0}:{1}", "MyAPI KEy", "MyName");
    var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));
    webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
    userid = CSContext.Current.User.Profile.User.UserID;
    var requestUrl = String.Format("{0}.xml", userid); // or .json
    var xml = webClient.DownloadString(requestUrl);
    System.Data.DataSet ds = new System.Data.DataSet();
    using (StringReader stringReader = new StringReader(xml))
                     ds = new System.Data.DataSet();

    Thanks & regards 


  • In reply to Adam Seabridge:

    Hi Adam Seabridge,

    Thanks for reply,

    I have using tellingent version 7.0. and i have create widget using c# file.
    and i have post my code in my last comment please check.
  • In reply to Parimal:

    So if this is a widget, why are you not using widget studio?
  • In reply to Luke D:

    Hi Luke Davidson,

    Actually, I have not much idea about widget studio programming. so I have created Widget using c# and create Dll then put in project.
  • In reply to Parimal:

    I would attempt to read the widget api documentation then
  • In reply to Luke D:

    Or try use the PublicApi (as opposed to REST) in your code
  • In reply to Luke D:

    I've written you an working widget example. See below.

    You really should read the documentation:

    #set($apiListResponse = $core_v2_role.List("%{Username = 'admin'}"))

    <h2>Roles for Admin</h2>

    #foreach($role in $apiListResponse)

  • In reply to Adam Seabridge:

    By the way go to the control panel here: /controlpanel/tools/ManageWidgets/ListWidgets.aspx

    click create new widget and add the code and save it. It should look like this when you place it on the page:

  • In reply to Parimal:

    var adminKey = String.Format("{0}:{1}", "MyAPI KEy", "MyName");

    Ensure that you have setup the API key on your site and you specify the username associated to this key (not the common/display name)

    var requestUrl = String.Format("{0}.xml", userid); // or .json

    Verify that your site is accessible via HTTPS from the server on which the widget is installed. If you're using a self-signed certificate for SSL, ensure that the server trusts this certificate.