WebサービスのPOSTメソッドは私にとって新しいものです。あなたは私が間違っていることを私に助けてくれますか?
WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
webClient.Encoding = Encoding.UTF8;
webClient.UploadStringCompleted += new UploadStringCompletedEventHandler((sender, e) =>
{
if (e.Error != null)
{
return;
}
string result = e.Result;
});
string uri = "http://localhost:60696/service/getlogin/";
StringBuilder postData = new StringBuilder();
postData.AppendFormat("/{0}/{1}", "username", HttpUtility.UrlEncode(textBox1.Text));
postData.AppendFormat("/{0}/{1}", "password", HttpUtility.UrlEncode(textBox2.Text));
webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
webClient.UploadStringAsync(new Uri(uri, UriKind.RelativeOrAbsolute),"POST", postData.ToString());
ちなみに、パラメータと値を追加してURLにアクセスすると、正常に機能します
このような("http://localhost:60696/service/getlogin/username,123,password,456").