Basic Authentication with Rest (RestSharp API)
Posted: Fri Mar 20, 2015 2:44 pm
Hello everyone,
I'm trying to use C# with the RestSharp API to pull data from the admin server and individual TM1 servers. I've managed to successfully get a list of online TM1 Servers from the admin server by sending a get request to "http://localhost:5895/api/v1/Servers"
This returns:
Based on this info I next try to send a get request to "http://192.168.141.131:45558/api/v1/Cubes?$select=Name" by using the following code:
So my question is... Does anyone know the proper way to use basic authentication? I'm doing something wrong, but I can't figure out what exactly. If someone could help put me on the right track, that would help a lot! 
Thanks in advance.
I'm trying to use C# with the RestSharp API to pull data from the admin server and individual TM1 servers. I've managed to successfully get a list of online TM1 Servers from the admin server by sending a get request to "http://localhost:5895/api/v1/Servers"
This returns:
Code: Select all
.....
{"Name":"GO_New_Stores","IPAddress":"192.168.141.131","IPv6Address":"","PortNumber":45557,"ClientMessagePortNumber":49173,"HTTPPortNumber":45558,"UsingSSL":true,"AcceptingClients":true}
......
Code: Select all
RestClient WebClient = new RestClient();
WebClient.BaseUrl = new Uri("http://192.168.141.131:45558/");
RestRequest CurrentRequest = new RestRequest();
WebClient.Authenticator = new HttpBasicAuthenticator("admin", "apple"); // Neither work
CurrentRequest = new RestRequest("api/v1/Cubes?$select=Name", Method.GET);
//CurrentRequest.AddHeader("Authorization", "Basic YWRtaW46YXBwbGU="); // Neither work
var queryresult = WebClient.Execute(CurrentRequest);
Console.WriteLine(queryresult.ResponseUri);
Console.WriteLine(queryresult.ErrorMessage); // returns "The operation has timed out"
Console.WriteLine(queryresult.ResponseStatus); // returns "TimedOut"
Console.WriteLine(queryresult.StatusDescription);
Console.WriteLine(queryresult.Content);
Console.WriteLine("Done writing.... :(");
Console.ReadLine();

Thanks in advance.