Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




ServiceManager.Admin.WhoAmI throws exception in TestApi sample application

api

I'm unable to connect to our gemini instance using the TestApi sample application.

I get an Exception : Unknown error, status code: Unauthorized

at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.FormLogin.btnOKClick1(Object sender, EventArgs e) in ..\Dev\ContersoftGeminiExamples\Samples\FormLogin.cs:line 29

The gemini instance is hosted in IIS 7.5, it isn't behind a firewall

If i try connecting using Windows Authentication: login = new ServiceManager("http://gemini", "domain\username", "", "", true);

I get a RestException : Unauthorized

If i try connection using UserName\Password with apiKey : login = new ServiceManager("http://gemini", "domain\username", "password", "apiKey", false);

I get an Exception : Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.FormLogin.btnOKClick1(Object sender, EventArgs e) in ..\Dev\ContersoftGeminiExamples\Samples\FormLogin.cs:line 31

User59373
· 1
User59373
Replies (10)
helpful
0
not helpful

Is the windows user that you are running under matches the user specified in code?


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

This is what I'm getting

[STAThread]
    static void Main()
    {
        string text = "";

        text += WhoAmI("http://gemini", WindowsIdentity.GetCurrent().Name, "", "apiKey", false);
        text += WhoAmI("http://gemini", WindowsIdentity.GetCurrent().Name, "pwd", "apiKey", false);
        text += WhoAmI("http://gemini", WindowsIdentity.GetCurrent().Name, "pwd", "", false);
        text += WhoAmI("http://gemini", WindowsIdentity.GetCurrent().Name, "", "apiKey", true);
        text += WhoAmI("http://gemini", WindowsIdentity.GetCurrent().Name, "", "", true);

        text += WhoAmI("http://geminiclient", WindowsIdentity.GetCurrent().Name, "", "apiKey", false);
        text += WhoAmI("http://geminiclient", WindowsIdentity.GetCurrent().Name, "pwd", "apiKey", false);
        text += WhoAmI("http://geminiclient", WindowsIdentity.GetCurrent().Name, "pwd", "", false);
        text += WhoAmI("http://geminiclient", WindowsIdentity.GetCurrent().Name, "", "apiKey", true);
        text += WhoAmI("http://geminiclient", WindowsIdentity.GetCurrent().Name, "", "", true);

        File.WriteAllText(@"C:\temp\WhoAmI.txt", text);
    }

    private static string WhoAmI(string url, string username, string password, string apiKey, bool windowsAuthentication)
    {
        string ret = "";

        try
        {
            ServiceManager serviceManager = new ServiceManager(url, username, password, apiKey, windowsAuthentication);

            serviceManager.Admin.WhoAmI();

            ret += "Success";
        }
        catch (Exception exception)
        {
            ret += exception.Message + Environment.NewLine;


            ret += exception.StackTrace+ Environment.NewLine+ Environment.NewLine+ Environment.NewLine;
        }

        return ret;
    }

Gives:

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unauthorized

Unauthorized

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Forbidden at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53

Unknown error, status code: Forbidden at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.BaseService.WhoAmI() at Test.Program.WhoAmId(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 53


User59373
· 1
User59373
helpful
0
not helpful

Are you running Gemini using windows authentication in the web.config file? If so, did you disable anonymous access in IIS?


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

the site is configured to use windows authentication and anonymous access is disabled.


User59373
· 1
User59373
helpful
0
not helpful

Can you please use Fiddler to see if the response is from IIS or Gemini?


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful
ANSWER

Ok, this is a bug in 5.1.3, which we are fixing for 5.1.5 (due out next week).


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

Note that it is only the WhoAmI method that has this issue. You should still be able to use the api.


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

I get the same issues when trying to get a list of users:

    [STAThread]
    static void Main()
    {
        string text = "";

        text += DoSomething("http://gemini", WindowsIdentity.GetCurrent().Name, "", "apiKey", false);
        text += DoSomething("http://gemini", WindowsIdentity.GetCurrent().Name, "pwd", "apiKey", false);
        text += DoSomething("http://gemini", WindowsIdentity.GetCurrent().Name, "pwd", "", false);
        text += DoSomething("http://gemini", WindowsIdentity.GetCurrent().Name, "", "apiKey", true);
        text += DoSomething("http://gemini", WindowsIdentity.GetCurrent().Name, "", "", true);

        File.WriteAllText(@"C:\temp\DoSomething.txt", text);
    }

    private static string DoSomething(string url, string username, string password, string apiKey, bool windowsAuthentication)
    {
        string ret = "";

        try
        {
            ServiceManager serviceManager = new ServiceManager(url, username, password, apiKey, windowsAuthentication);

            List<Countersoft.Gemini.Commons.Entity.User> users = serviceManager.User.GetUsers().Select(p => p.Entity).ToList();

            ret += "Success";
        }
        catch (Exception exception)
        {
            ret += exception.Message + Environment.NewLine;


            ret += exception.StackTrace+ Environment.NewLine+ Environment.NewLine+ Environment.NewLine;
        }

        return ret;
    }

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.UserService.GetUsers() at Test.Program.DoSomething(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 38

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.UserService.GetUsers() at Test.Program.DoSomething(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 38

Unknown error, status code: Unauthorized at Countersoft.Gemini.Api.BaseService.GetResponse[T](IRestRequest request) at Countersoft.Gemini.Api.UserService.GetUsers() at Test.Program.DoSomething(String url, String username, String password, String apiKey, Boolean windowsAuthentication) in ..\Dev\ContersoftGeminiExamples\Samples\Program.cs:line 38

Unauthorized

Unauthorized


User59373
· 1
User59373
helpful
0
not helpful

You need to be a Gemini Administrator to do that.


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

Excellent! Looks like I'm up and running. Thanks for your assistance.


User59373
· 1
User59373