Using https with RestSharp

3,626 views
Skip to first unread message

Paul Johnson

unread,
Jul 15, 2013, 1:28:02 PM7/15/13
to rest...@googlegroups.com
Hi,

I have a very simple test rig set up for some services on a remote server. The problem is that the protocol is https rather than http.

While the URL goes in fine, I am getting an error that says there are no services on http://

Am I doing something wrong is will RestSharp not handle https calls?

Demo code goes like this

private void startTest() 
 string email = "bo...@example.com"; 
 string password = "password";
 doRestSharpWebRequest(email, password);
 }

private void doRestSharpWebRequest(email, password) 
 var restClient = new RestClient();
 restClient.BaseUrl = "https://mytestserver.com/api";
 restClient.Authenticator = new SimpleAuthenticator("email", email, "password", password);
 var restRequest = new RestRequest("token", Method.GET);
 restRequest.AddHeader("Accepts", "application/json;version=1");
 restRequest.AddHeader("Authorization", "apikey zyzyz");
 restRequest.RequestFormat = DataFormat.Json;
 IRestResponse<userlogin> response = restClient.Execute<userlogin>(restRequest); 
}

When I run the code, I'm getting the following back


Message = No HTTP resource was found that matches the request URI 'http://mytestserver.com/api/token?Email=bob%40example.com&password=password'


Thanks


Paul

David Fernández Martínez

unread,
Jul 24, 2013, 4:25:41 AM7/24/13
to rest...@googlegroups.com
I have the same problem. I put "https" in my code and I can see that it changes to "http" in debug mode.
Reply all
Reply to author
Forward
0 new messages