RestSharp の v130 を使用した非常に単純なコードがあります。コード自体は正常にコンパイルされ、サーバーから値を返します。問題は、それらが私が求めているものではないことです。
コード
private void startTest()
{
string email = "bob2@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);
}
userlogin は、デシリアライズする単なるクラスです。
コードを実行すると、次のエラーが表示されます
Message = No HTTP resource was found that matches the request URI 'http://mytestserver.com/api/token?Email=bob%40example.com&password=password'.
問題が発生するはずの @ が %40 に変更されたことと、http が https に変更されたことの 2 つが明らかです。
https と http から変換しないように restsharp に指示できますか?